Skip to content

Commit 3d10758

Browse files
swabbassyogevbd
andauthored
Status bar updates causes ui freeze on some devices (#7231)
Modify flags for DecorView in the global main thread handler caused ui to freeze when calling `mergeOptions` inside useEffect. This happens on Samsung devices with Android 9, that seems it has issues internally since it is not reproduce on emulator and other devices including Samsungs with new android versions. The workaround was to set the flags in a task to run in the DecorView MessageQueue in order to ensure flags are set when the DecorView is ready internally to accept changes. Co-authored-by: Yogev Ben David <yogev132@gmail.com>
1 parent ec34501 commit 3d10758

File tree

1 file changed

+11
-8
lines changed
  • lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller

1 file changed

+11
-8
lines changed

lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,18 @@ private void setTextColorScheme(StatusBarOptions statusBar) {
136136
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
137137

138138
final View view = activity.getWindow().getDecorView();
139+
//View.post is a Workaround, added to solve internal Samsung
140+
//Android 9 issues. For more info see https://github.com/wix/react-native-navigation/pull/7231
141+
view.post(()->{
142+
int flags = view.getSystemUiVisibility();
143+
if (isDarkTextColorScheme(statusBar)) {
144+
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
145+
} else {
146+
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
147+
}
139148

140-
int flags = view.getSystemUiVisibility();
141-
if (isDarkTextColorScheme(statusBar)) {
142-
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
143-
} else {
144-
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
145-
}
146-
147-
view.setSystemUiVisibility(flags);
149+
view.setSystemUiVisibility(flags);
150+
});
148151
}
149152

150153
private void mergeStatusBarOptions(View view, StatusBarOptions statusBar) {

0 commit comments

Comments
 (0)