-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android app restarts and lose place when folding/unfolding phone #6693
Comments
Other configuration changes that will have similar impact
|
Reproduced this issue w a screen recording: PlatformAndroid Device InfoSamsung Galaxy Fold 4. Currently running Android 14 (OneUI Version 6.1.1) App VersionBuild version: 1.94.0.402; Bundle info: 3c30bb1 (prod); Bundle date: 24111623; Platform: android; Platform version: 34 Screen RecordingXRecorder_24112024_112614.mp4Just like OP, I'm not sure if scrolling back to current place in timeline is doable/how hard it is. But would be nice if the app didn't restart fully on state change. |
Would be nice to figure out what causes the restart! I don't think our code is doing this intentionally |
Let me know if there's anything I can do to help debug :) I'm an sdet with too much time on their hands, so I'd love to be useful haha |
I'm guessing there isn't much test-oriented follow up here, if you'd like to dig into the cause I'd assume it's something related to the Android manifest settings and whatever Expo is using as a default. Since the screen size changes, it might be possible that the app is not currently resilient to that anyway, in which case we'd have to fix that first before making this seamless. If you can dig into the root cause (e.g. the Android manifest setting that tweaks this behavior), that would be helpful, but you'd probably have to run the build locally to do that. Alternatively, if you'd like to help with the project in general, looking over other issues and trying to record repro cases is very useful. Thank you. |
Sounds good, thank you! I've definitely been looking through some issues and recording repros already 😊 |
I think this could help: https://reactnavigation.org/docs/state-persistence/ Something to do with saving state in Android: https://developer.android.com/topic/libraries/architecture/saving-states |
I'll take a look in a bit! |
A resizing of the screen triggers a configuration change. A configuration change restarts your Android Activity or fragment. If you don't restore state properly in that context then you can end up with state loss. |
You can test configuration changes by enabling orientation change on debug builds, and then use that across the app to see how well you recover per screen. (If it's indeed configuration change related) |
Does configuration change always restart an activity? |
You can edit your manifest and tell it that you're handling some changes yourself, but I'm not sure it allows all config changes. https://developer.android.com/guide/topics/resources/runtime-changes But activity recreation can happen in other cases as well, so the key is to always make sure you restore state |
Steps to Reproduce
Observed:
I'm back at the start of my feed, no way to get back to the post I was on.
Expected:
The app restores the screen I was last on: in this case, viewing a specific post.
Ideally it would also restore my scroll position in the feed, but maybe that's a separate fix.
Attachments
No response
What platform(s) does this occur on?
Android
Device Info
Pixel fold 2, Android 15
What version of the app are you using?
Build version: 1.94.0.402; Bundle info: c59dc0d (prod); Bundle date: 24112017; Platform: android; Platform version: 35
Additional Information
Two ways to solve this
implement saving the app state to a bundle and restoring from that bundle in onCreate. (This technique also helps with other situations, e.g. if the app is killed due to low memory)
Or, handle screen resize configuration changes by adding them to your activity tag in the manifest, and then resizing in onConfigurationChange. (Harder, doesn't solve situations where app is killed)
The text was updated successfully, but these errors were encountered: