Skip to content
New issue

Have a question about this project?Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of serviceand privacy statement.We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splash screen jumps on initial load (android prebuild) #21036

Open
jjenzzopened this issue Feb 1, 2023 · 34 comments
Open

Splash screen jumps on initial load (android prebuild) #21036

jjenzzopened this issue Feb 1, 2023 · 34 comments
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@jjenzz
Copy link

jjenzz commented Feb 1, 2023

Summary

moving this fromexpo/router#240

when moving to prebuild (npx expo prebuild) from a fresh install (npx create-react-native-app -t with-router) the splash screen will jump up for one frame on android during app load.

Note:this does not happen in managed workflow

you can slow the following video frame-by-frame to see what i mean:

CleanShot.2023-01-31.at.14.22.06.mp4

the two frames where the jump occurs (i've drawn a redline to highlight the difference in position):

image

while it is hard to catch this with the naked eye in this demo, the jump is much more prominent in our real-world app that takes a little longer to load.

i'm not entirely sure if this is a router issue or more generic expo issue so happy to move it to the correct place if there is somewhere more suitable.

What platform(s) does this occur on?

Android

Environment

expo-env-info 1.0.5 environment info:
System:
OS: macOS 12.5.1
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.7.0 -~/.nvm/versions/node/v18.7.0/bin/node
Yarn: 1.22.19 -~/.nvm/versions/node/v18.7.0/bin/yarn
npm: 8.15.0 -~/.nvm/versions/node/v18.7.0/bin/npm
Watchman: 2022.12.12.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8815526
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
npmPackages:
expo:~47.0.12 =>47.0.13
react: 18.1.0 =>18.1.0
react-dom: 18.1.0 =>18.1.0
react-native: 0.70.5 =>0.70.5
react-native-web:~0.18.7 =>0.18.12
npmGlobalPackages:
eas-cli: 2.1.0
expo-cli: 6.0.8
Expo Workflow: bare

Minimal reproducible example

https://github /jjenzz/expo-splash-jump

@jjenzz jjenzz added the needs validation Issue needs to be validated label Feb 1, 2023
@george-thomas-hill
Copy link

I have encountered this, too.

@brentvatne brentvatne added needs review Issue is ready to be reviewed by a maintainer and removed needs validation Issue needs to be validated labels Feb 22, 2023
@Edmundoacosta
Copy link

I have the same issue:(

@matuskropuch
Copy link

Same issue here

@pleopardi
Copy link

Same here.
Can't use the StatusBar component from expo-status-bar to handle it because it happens before the JS code takes over.

@ChromeQ
Copy link

ChromeQ commented Jun 11, 2023

I am also experiencing this issue and is very prominent on a "real world" app, I also assumed this has to do with the status bar but yet to have the time to investigate and test properly but good to know from@pleopardiI may be wasting my time on that!

An expo sdk fix would be preferred

@pleopardi
Copy link

From what I read in other issues, it's probably some configuration to add in styles.xml, but I couldn't figure it out yet.

The "jump" happens the moment the status bar is displayed while the splash screen is still visible.

@kurucaner
Copy link

kurucaner commented Jun 29, 2023

This solution worked for me: I removed the expo-status-bar from my project and I added the following properties to app.json

{
expo: {
"androidStatusBar": {
"barStyle": "light-content",
"backgroundColor": "#060047",
"translucent": true
},
}
}

@ChronoByteCosmonaut
Copy link

Same here, hope this gets fixed soon!!

@ChronoByteCosmonaut
Copy link

This solution worked for me: I removed the expo-status-bar from my project and I added the following properties to app.json

{
expo: {
"androidStatusBar": {
"barStyle": "light-content",
"backgroundColor": "#060047",
"translucent": true
},
}
}

This is a good solution but makes the statusbar semi-transparent.

@nelsonyang0710
Copy link

This solution worked for me: I removed the expo-status-bar from my project and I added the following properties to app.json

{
expo: {
"androidStatusBar": {
"barStyle": "light-content",
"backgroundColor": "#060047",
"translucent": true
},
}
}

This is a good solution but makes the statusbar semi-transparent.

the same issue happens here and I can't make the status bar to transparent even set the background color to #00000000..

@TheEndurance
Copy link

Are there any solutions to this other than uninstalling the expo-status-bar package?

@cavemon
Copy link

cavemon commented Nov 8, 2023

This solution worked for me: I removed the expo-status-bar from my project and I added the following properties to app.json

{
expo: {
"androidStatusBar": {
"barStyle": "light-content",
"backgroundColor": "#060047",
"translucent": true
},
}
}

@TheEnduranceWe followed this solution above and it seems to have worked. The status bar on Android appears a bit different, but the splash screen logo no longer jumps and we didn't uninstall anything.

@techgerm
Copy link

techgerm commented Feb 2, 2024

Is anyone else having trouble uninstallingexpo-status-bar?🙃

Our expo app is inside an Nx monorepo and I've:

  1. Uninstalledexpo-status-bar
  2. Removed all references toexpo-status-barincluding"expo-status-bar": "*"
  3. Cleared bundler caches by followingthese instructions

And I'm still seeing this when I try to build android:

Screenshot 2024-02-01 at 4 01 43 PM

Screenshot 2024-02-01 at 4 02 10 PM

@ChromeQ
Copy link

ChromeQ commented Feb 2, 2024

@techgermMaybe something else is installing it as a dependency. Can you show us the output of the following command:

npm ls expo-status-bar

@techgerm
Copy link

techgerm commented Feb 2, 2024

hmm yeah that was my first intuition so I checked ouryarn.lockto see if it was included in any other dependencies and nothing found 😕

here's the output ofnpm ls expo-status-bar:
Screenshot 2024-02-01 at 4 13 22 PM

@AndreiRadchenko
Copy link

This is my thoughts about this issue.
If you callStatusBar.setTranslucent(true)while SplashScreen visible, SplashScreen leaps. If you call it when app screen is visible — app screen will leap.
To address this issue, I tied the event of adjusting StatusBar to the moment one frame before SplashScreen is replaced by app screen. I've sat SplashScreen"resizeMode": "cover",so SplashScreen image gets a bit enlarged before it disappears. Something like one frame animation. And it looks better than layout leap when StatusBar become translucent on SplashScreen or app screen.

App.js

constonLayoutRootView=useCallback(async()=>{
if(fontsLoaded){
awaitdelay(
()=>
StatusBar.pushStackEntry({
barStyle:'dark-content',
translucent:true,
animated:true,
backgroundColor:'transparent',
}),
2000// 2 sec delay for loading and render data
);
delay(SplashScreen.hideAsync,33);// hide SplashScreen one frame after StatusBar gets translucent
}
},[fontsLoaded]);

if(!fontsLoaded){
returnnull;
}

I make use of delay function for delayed execution of callback passed to it.

delay.js

exportconstdelay=(fun,timeout)=>
newPromise((resolve)=>setTimeout(resolve,timeout))
.then(fun)
.catch((e)=>console.log(e.message));

@brentvatne
Copy link
Member

related:#28528

@buildnewapp
Copy link

Because expo-router is used,i can't remove expo-status-bar; Are there any other good solutions?

The causes of startup graph jitter are:
SplashScreen.preventAutoHideAsync();
setTimeout(SplashScreen.hideAsync, 2000);

The easiest way is not to call SplashScreen.preventAutoHideAsync, is there any other component or method to delay the start screen?

@miteshdevg
Copy link

expo start --no-dev --minify
use above command for start Expo

@Episodex
Copy link

Episodex commented Jul 1, 2024

I have the same issue. It's especially annoying when app starts in dark mode, as the bar is still in light mode when it's visible. Then it disappears and splash screen shifts a bit. It's very noticeable.

@miteshdevg
Copy link

I have the same issue. It's especially annoying when app starts in dark mode, as the bar is still in light mode when it's visible. Then it disappears and splash screen shifts a bit. It's very noticeable.

you can test it into other device

@ChromeQ
Copy link

ChromeQ commented Jul 2, 2024

The problem is that even if your commandexpo start --no-dev --minifyworks, it would only affect development and we are seeing this on a standalone production build.
Also, telling somebody to try another device is not really helpful, it's unlikely it is only this one device with the problem when there are dozens of folks on here saying the same thing.

@spicy-xili
Copy link

Any news on this? What is the current solution or fix?

@miteshdevg
Copy link

Any news on this? What is the current solution or fix?

in my side,it's automatic working I don't how please check your network connection

@homocodian
Copy link

This solution worked for me: I removed the expo-status-bar from my project and I added the following properties to app.json

{
expo: {
"androidStatusBar": {
"barStyle": "light-content",
"backgroundColor": "#060047",
"translucent": true
},
}
}

will it work for light and dark splash screens?

@brentvatne
Copy link
Member

this is a tricky problem to solve for in a generic way with the current way that layout is handled on android. we're working with@zoontekon moving towards recommending and defaulting toedge to edge layoutwhich will simplify this greatly. until then, thank you to folks in this thread for helping each other out!

@Episodex
Copy link

This solution worked for me: I removed the expo-status-bar from my project and I added the following properties to app.json

{
expo: {
"androidStatusBar": {
"barStyle": "light-content",
"backgroundColor": "#060047",
"translucent": true
},
}
}

will it work for light and dark splash screens?

I tried this and it solved the issue for me for both light mode and dark mode. Not sure why it works also on dark mode to be honest, but I tested it for both Android and iOS and seems to work fine, so I won't dig more into it. Maybe it works only if the status bar has the same color as the app's background but that's fine for me. Thanks!

@tim7on
Copy link

tim7on commented Aug 28, 2024

So I had same problem today, and I found out on reddit, thatReanimatedhook cause it.
if You use somewhere in app hookuseAnimatedKeyboardinit it with this argisStatusBarTranslucentAndroid,

example:
useAnimatedKeyboard({ isStatusBarTranslucentAndroid: true, })

@ChromeQ
Copy link

ChromeQ commented Aug 28, 2024

I don't use that hook so that isn't the cause. Could you at least provide a link so that people who are willing to try it out can take a look for themselves.

@tim7on
Copy link

tim7on commented Aug 28, 2024

I don't use that hook so that isn't the cause. Could you at least provide a link so that people who are willing to try it out can take a look for themselves.

Yes of course here is thelink to the reddit

@beshoo
Copy link

beshoo commented Sep 11, 2024

Still on some Samsung mobiles, this clunky shaking happened even withe the previous fixes.

It is something expo has to fix it.. We can not give the client a clunky app.. His brand stand on the splash screen.... But a jumping splash... No way

@avega99
Copy link

avega99 commented Sep 15, 2024

I am having the same issue:/ I tried deleting expo status bar but it didn't work

@mpho-ppm
Copy link

mpho-ppm commented Sep 25, 2024

This is what I used to fix this issue

I added aandroidStatusBarobject to the app.json and a transparent background colour

"androidStatusBar": {
"backgroundColor": "#00000000"
}

I created this plugin in it's own file calledwithAndroidSplashScreen.tsand added it as my plugin on the app.json file

const { AndroidConfig, withStringsXml } = require('@expo/config-plugins');

const withAndroidSplashScreen = (expoConfig) =>
withStringsXml(expoConfig, (modConfig) => {
modConfig.modResults = AndroidConfig.Strings.setStringItem(
[
{
_: 'true',
$: {
name: 'expo_splash_screen_status_bar_translucent',
translatable: 'false'
}
}
],
modConfig.modResults
);
return modConfig;
});


module.exports = withAndroidSplashScreen;

After making these changes, my splash screen stopped jumping when starting the app..

It needs a new build since the changes are on the app.json file

I found the solution here and it explains why the issue is happening -https:// aronberezkin /posts/a-step-by-step-guide-to-writing-your-first-expo-config-plugin

Screenshot 2024-09-25 at 19 45 59 Screenshot 2024-09-25 at 19 49 28

Goodluck I hope it helps

@zoontek
Copy link
Contributor

zoontek commented Oct 13, 2024

You can addreact-native-edge-to-edgeto your project for enabling edge-to-edge display on Android.

Paired withreact-native-bootsplash,it fixes this anoying jump issue. It will also work well with expo-splash-screen in Expo 52.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests