Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e787acf authored by wilsonshih's avatar wilsonshih
Browse files

Ensure splash screen removed after it's view is shown in render thread.

For the client rendering, there is no guarantee the frame is draw
complete when next traversal start. Hide and remove splash screen
window after the frame was commit in render thread.

Flag: com.android.window.flags.use_rt_frame_callback_for_splash_screen_transfer
Bug: 387231234
Test: run test 10+ times on emulator.
Change-Id: I338f6bf263d132c221ce575b9bd526e4662df1b8
parent d555e2c9
Loading
Loading
Loading
Loading
+26 −3
Original line number Original line Diff line number Diff line
@@ -4734,6 +4734,7 @@ public final class ActivityThread extends ClientTransactionHandler
    }
    }


    private void reportSplashscreenViewShown(IBinder token, SplashScreenView view) {
    private void reportSplashscreenViewShown(IBinder token, SplashScreenView view) {
        Trace.instant(Trace.TRACE_TAG_VIEW, "reportSplashscreenViewShown");
        ActivityClient.getInstance().reportSplashScreenAttached(token);
        ActivityClient.getInstance().reportSplashScreenAttached(token);
        synchronized (this) {
        synchronized (this) {
            if (mSplashScreenGlobal != null) {
            if (mSplashScreenGlobal != null) {
@@ -4751,11 +4752,33 @@ public final class ActivityThread extends ClientTransactionHandler
        final SurfaceControl.Transaction transaction = new SurfaceControl.Transaction();
        final SurfaceControl.Transaction transaction = new SurfaceControl.Transaction();
        transaction.hide(startingWindowLeash);
        transaction.hide(startingWindowLeash);


        decorView.getViewRootImpl().applyTransactionOnDraw(transaction);
        view.syncTransferSurfaceOnDraw();
        view.syncTransferSurfaceOnDraw();
        // Tell server we can remove the starting window

        if (com.android.window.flags.Flags.useRtFrameCallbackForSplashScreenTransfer()
                && decorView.isHardwareAccelerated()) {
            decorView.getViewRootImpl().registerRtFrameCallback(
                    new HardwareRenderer.FrameDrawingCallback() {
                        @Override
                        public void onFrameDraw(long frame) { }
                        @Override
                        public HardwareRenderer.FrameCommitCallback onFrameDraw(
                                int syncResult, long frame) {
                            return didProduceBuffer -> {
                                Trace.instant(Trace.TRACE_TAG_VIEW, "transferSplashscreenView");
                                transaction.apply();
                                // Tell server we can remove the starting window after frame commit.
                                decorView.postOnAnimation(() ->
                                        reportSplashscreenViewShown(token, view));
                            };
                        }
                    });
        } else {
            Trace.instant(Trace.TRACE_TAG_VIEW, "transferSplashscreenView_software");
            decorView.getViewRootImpl().applyTransactionOnDraw(transaction);
            // Tell server we can remove the starting window after frame commit.
            decorView.postOnAnimation(() -> reportSplashscreenViewShown(token, view));
            decorView.postOnAnimation(() -> reportSplashscreenViewShown(token, view));
        }
        }
    }


    /**
    /**
     * Cycle activity through onPause and onUserLeaveHint so that PIP is entered if supported, then
     * Cycle activity through onPause and onUserLeaveHint so that PIP is entered if supported, then
+11 −0
Original line number Original line Diff line number Diff line
@@ -425,6 +425,17 @@ flag {
    }
    }
}
}


flag {
    name: "use_rt_frame_callback_for_splash_screen_transfer"
    namespace: "windowing_frontend"
    description: "report SplashscreenView shown after RtFrame commit"
    is_fixed_read_only: true
    bug: "387231234"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
flag {
    name: "port_window_size_animation"
    name: "port_window_size_animation"
    namespace: "windowing_frontend"
    namespace: "windowing_frontend"