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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android freeze not working if layout changes since >= 3.30.0 #2349

Closed
adxzhang1 opened this issue Sep 24, 2024 · 2 comments
Closed

Android freeze not working if layout changes since >= 3.30.0 #2349

adxzhang1 opened this issue Sep 24, 2024 · 2 comments
Assignees
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided

Comments

@adxzhang1
Copy link

adxzhang1 commented Sep 24, 2024

Description

Since react-native-screens: >= 3.30.0, using freezeOnBlur: true in @react-navigation/bottom-tabs or using enableFreeze directly from react-native-screens, tabs that are not in focus still trigger onLayout changes for the following scenarios:

  • rotating the device
  • changing status bar visibility
  • changing fullscreen mode

I would expect that a tab which is not in focus to not undergo a layout change.

Notice in the video, when rotating the device, the home page, which is not in focus, still has a layout change.

video.mp4

Steps to reproduce

  1. Use freezeOnBlur: true in Tab.Navigator screenOptions from @react-navigation/bottom-tabs or directly call enableFreeze from react-native-screens
  2. Switch to a new tab
  3. Rotate the device OR have the change status bar visibility OR change fullscreen mode
  4. Notice how layout changes occur for a view that is not in focus

Snack or a link to a repository

https://github.com/adxzhang1/react-native-screens/tree/unfocus-freeze

Screens version

>= 3.30.0

React Native version

>= 0.72

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: Android This issue is specific to Android labels Sep 24, 2024
@alduzy alduzy self-assigned this Sep 26, 2024
@alduzy
Copy link
Member

alduzy commented Sep 30, 2024

@adxzhang1 Thanks for submitting the issue! I can confirm that the issue is reproducible and I'm working on a possible fix.

@kkafar
Copy link
Member

kkafar commented Oct 16, 2024

Hey, @adxzhang1 I believe the freeze works as expected. If you try to trigger the render of the component you have set the onLayout callback on, e.g. by setting state in the callback - you will notice that the component won't render.

Currently we're unsure why the onLayout is triggered, we're even unsure whether this is an invalid behaviour. The leading hypothesis is that this is just divergence in react-native behaviour between platforms.

I'm closing the issue, because it seems that the freeze works as expected (preventing renders).

If you believe that I should not close the issue & that this behaviour is problematic let us know about the use case.

@kkafar kkafar closed this as completed Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants