diff --git a/src/Expensify.tsx b/src/Expensify.tsx index 82900c0ef0a66..76a097ce347f9 100644 --- a/src/Expensify.tsx +++ b/src/Expensify.tsx @@ -136,9 +136,11 @@ function Expensify() { const isSplashReadyToBeHidden = splashScreenState === CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN; const isSplashVisible = splashScreenState === CONST.BOOT_SPLASH_STATE.VISIBLE; + const [splashHideHasBeenCalled, setSplashHideHasBeenCalled] = useState(false); const shouldInit = isNavigationReady && hasAttemptedToOpenPublicRoom && !!preferredLocale; const shouldHideSplash = shouldInit && (CONFIG.IS_HYBRID_APP ? isSplashReadyToBeHidden : isSplashVisible); + const shouldRenderSplashScreenHider = !splashHideHasBeenCalled && splashScreenState !== CONST.BOOT_SPLASH_STATE.HIDDEN; // We store this in a ref to get the latest values in BootsplashMonitor callback const gateStatusRef = useRef(null); @@ -199,7 +201,6 @@ function Expensify() { Navigation.setIsNavigationReady(); }, []); - const [splashHideHasBeenCalled, setSplashHideHasBeenCalled] = useState(false); const onSplashHide = useCallback(() => { setSplashHideHasBeenCalled(true); setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN); @@ -294,7 +295,7 @@ function Expensify() { initialUrl={initialUrl} /> )} - {!splashHideHasBeenCalled && ( + {shouldRenderSplashScreenHider && ( (() => ({ @@ -32,24 +32,31 @@ function SplashScreenHider({shouldHideSplash, onHide}: SplashScreenHiderProps): hideHasBeenCalled.current = true; - BootSplash.hide().then(() => { - scale.set( - withTiming(0, { - duration: 200, - easing: Easing.back(2), - }), - ); + // Set RN splash visible, then wait two frames to ensure it's painted + // before hiding the native BootSplash. + opacity.set(1); + requestAnimationFrame(() => { + requestAnimationFrame(() => { + BootSplash.hide().then(() => { + scale.set( + withTiming(0, { + duration: 200, + easing: Easing.back(2), + }), + ); - opacity.set( - withTiming( - 0, - { - duration: 250, - easing: Easing.out(Easing.ease), - }, - () => scheduleOnRN(onHide), - ), - ); + opacity.set( + withTiming( + 0, + { + duration: 250, + easing: Easing.out(Easing.ease), + }, + () => scheduleOnRN(onHide), + ), + ); + }); + }); }); });