react-native-screens icon indicating copy to clipboard operation
react-native-screens copied to clipboard

When I want to go to the previous page, everything suddenly disappears

Open ugurdalkiran opened this issue 2 years ago • 16 comments

Description

I'm opening a new page on Android and everything is fine. When I want to come back from that opened page, all Views and Texts disappear from the screen. A white screen appears. Then my back page opens.

At this stage, I want the objects on my screen not to disappear.

In my opinion such a problem occurs when FABRIC is enabled. If fabric is not enabled, everything continues as normal. Could it be that the react-navigation package's fabric support is not working properly?

Here is the video.

https://user-images.githubusercontent.com/27302986/191944841-4caf6c35-7395-4329-8203-6ef68ff352a6.mp4

"react": "18.2.0",
"react-native": "0.71.0",
---
"@react-navigation/native": "6.1.2",
"@react-navigation/native-stack": "6.9.8",
"react-native-gesture-handler": "2.9.0",
"react-native-safe-area-context": "4.4.1"
"react-native-screens": "3.18.2"

<GestureHandlerRootView style={{ flex: 1 }}>
	<NavigationContainer>
		<Stack.Navigator
		screenOptions={{
			headerMode: "screen"
		}}
		initialRouteName="Home">
		<Stack.Screen name="Home" component={Home} />
		<Stack.Screen
			name="Page"
			component={Page}
			options={{ animation: "slide_from_right" }}
		/>
		</Stack.Navigator>
	</NavigationContainer>
</GestureHandlerRootView>

props.navigation.navigate("Page");
props.navigation.goBack();

Steps to reproduce

  1. I go to a page.
  2. I click the back button.
  3. Everything disappears. A white page appears instantly and the previous page opens.

Snack or a link to a repository

https://stackoverflow.com/help/mcve

Screens version

3.18.2

React Native version

0.71.0

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

Android emulator

Device model

No response

Acknowledgements

Yes

ugurdalkiran avatar Jan 17 '23 13:01 ugurdalkiran

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar Jan 17 '23 13:01 github-actions[bot]

@kkafar

I have now installed the updated version (3.19.0) and checked again but the problem persists. 😥

Probably the problem is not related to the react-native-screens package. Can we say that the problem is caused by the react-navigation package?

ugurdalkiran avatar Jan 18 '23 07:01 ugurdalkiran

Hi @ugurdalkiran!

Probably the problem is not related to the react-native-screens package. Can we say that the problem is caused by the react-navigation package?

No, the problem definitely lies in react-native-screens, moreover we are aware that this problem exists. It is caused by change of order in which views are unmounted on new architecture, that is leafs to root (bottom - top) ==> child views are unmounted before the transition begins. On Paper it was not the case, because the order was opposite - root to leafs (top - bottom).

We still need to find a proper solution to this problem.

kkafar avatar Jan 18 '23 08:01 kkafar

I am glad that you are aware of the problem and that you are looking for a solution.

I hope it will be resolved as soon as possible, thanks for your efforts. ❤️

ugurdalkiran avatar Jan 18 '23 08:01 ugurdalkiran

Similar problem happening on iOS, without Fabric enabled.

The screen goes blank and just like flies out of place instead of animating out.

Before (correct)

Here is screens version 3.11.1:

https://user-images.githubusercontent.com/13172299/214119945-0269b941-9a50-402d-bb7f-183abdaac4d7.mov

After

Here is 3.18.2.

Notice it looks weird when going back. If I swipe back, it works fine. The issue only happens if I call goBack()/use the back button.

https://user-images.githubusercontent.com/13172299/214120332-694d185f-4157-4df5-b282-dd2b3b908af6.mov

Any idea which version this started with? Would be useful to downgrade to avoid it happening. Thank you!

nandorojo avatar Jan 23 '23 18:01 nandorojo

It seems to be the same issue as this: https://github.com/software-mansion/react-native-screens/issues/1532 Although the one I linked to is Reanimated 2

miladdev85 avatar Jan 24 '23 16:01 miladdev85

Similar problem happening on android with fabric enabled "@react-navigation/native": "^6.1.6", "@react-navigation/native-stack": "^6.9.12", "react": "18.2.0", "react-native": "0.71.7", "react-native-safe-area-context": "^4.5.2", "react-native-screens": "^3.20.0"

dppo avatar May 08 '23 09:05 dppo

same issue here +1

platform ios library version all lastest

enable fabric and using some navigation method (reset , replace)

any solution?

RyuWoong avatar Aug 29 '23 07:08 RyuWoong

Might be related to https://github.com/software-mansion/react-native-screens/issues/1661

TwistedMinda avatar Aug 31 '23 11:08 TwistedMinda

Hi @ugurdalkiran!

Probably the problem is not related to the react-native-screens package. Can we say that the problem is caused by the react-navigation package?

No, the problem definitely lies in react-native-screens, moreover we are aware that this problem exists. It is caused by change of order in which views are unmounted on new architecture, that is leafs to root (bottom - top) ==> child views are unmounted before the transition begins. On Paper it was not the case, because the order was opposite - root to leafs (top - bottom).

We still need to find a proper solution to this problem.

Please is there a quick fix or any hack to get around this behaviour. Thanks for your reply

Obhenimen avatar Nov 23 '23 16:11 Obhenimen

Hi everyone! I know that this problem is unfortunately still relevant and I want to really say sorry that some of you may experience it. From our side we're still waiting to merge @WoLewicki PR to official React Native repo about adding listeners for screen mount operations so we could perform proper logic when the screen will unmount on Android. With those listeners it will be possible to fix this issue, but for now we only have to wait 😓

tboba avatar Nov 24 '23 12:11 tboba

Hey @tboba @WoLewicki @kkafar

I think react-native team hasn't accepted this PR (unfortunately 😔). Are you planning to create any fixes for that (maybe you have some other ideas on how to fix it)?

As I can understand the problem now is that views are getting actually removed from the screen before root Screen component receives the same event, right (i. e. when Screen component get this event - at this point of time all childs already removed)?

kirillzyusko avatar Apr 29 '24 14:04 kirillzyusko

Hi @kirillzyusko! Yeah, we know this PR has been rejected, sadly 😢 AFAIK, currently @kkafar is working on possible fix for that bug, do you know Kacper what's the current state of it? About the second thing - yes, that's exactly why all of the elements are gone on going backwards.

tboba avatar Apr 29 '24 14:04 tboba

@tboba Cool, glad to hear that progress is moving 😎

I just thought to suggest that potentially we can pospone unmounting a component in JS (I guess it's managed by react-navigation). Just potentially instead of excluding a component from JS tree we can assign a new prop (like removing=true/false) and actually remove a component only when transition has completed.

But I'll be glad to hear how you managed to overcome this problem 💪 👀

kirillzyusko avatar Apr 29 '24 15:04 kirillzyusko