fix: StatusBar race conditions#1074
Merged
kirillzyusko merged 1 commit intomainfrom Aug 9, 2025
Merged
Conversation
Contributor
📊 Package size report
|
|
Hi @kirillzyusko, I think the bug is still present on older Android devices — more details in #1181. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Fixed a problem when
StatusBarcan manipulate its properties beforeEdgeToEdgeview was attached to the hierarchy.💡 Motivation and Context
The original problem stems from the fact, that sometimes
StatusBarmodule may handle setters earlier, thanEdgeToEdgeview was attached. As a result it adds undesired paddings and may break the keyboard controller logic.The first my idea was adding a condition
if (view() == null) { return }. However it's not very reliable, because some apps may usekeyboard-controllerfeatures (OverKeyboardView,KeyboardBackgroundViewetc.) withoutKeyboardProvider. In this case thereact-native-keyboard-controllerwill break allStatusBarmanipulations, so it's not the solution.I started to investigate further and found out that we actually have a race condition: view may be created but not attached to hierarchy yet. In this case we forward call to original implementation. Here I wanted to fix it with code that will reset all flags that were set by StatusBar. But again the trick didn't work, because the pipeline is next:
So I had to put the code in
onAttachedToWindowlifecycle, but I think it would make code more complicated/harder to debug in future. So I decided to re-work approach a little bit. Instead of using hierarchy as source of truth I added a registry, that holds a reference. In this case I can get more synchronous access and be sure that there is no potential race conditions.Closes #993
📢 Changelog
Android
EdgeToEdgeViewRegistry;EdgeToEdgeViewRegistryfor detectingEdgeToEdgeview/its properties.🤔 How Has This Been Tested?
Tested manually on Pixel 9 PRO API 31 (emulator) with double "R" reload. Issue was reproducible more frequently if you would try to reload during reload. Or if you open first screen and then do a reload.
📸 Screenshots (if appropriate):
Screen.Recording.2025-08-09.at.15.53.03.mov
📝 Checklist