-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
Changes fragment commit to synchronous #1066
Conversation
@Ubax I'm not sure if you are aware, but this change also fixes an issue where the app's background may be visible for half a second, causing an ugly flash. This is great! However, it does seem to still lag under a new case, which didn't happen before. Please take a look at the last video from this comment: #1020 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this change as long as it does not break anything :)
One comment I left is about method naming. I think that we shold not leave the old naming in place as the names were chosen to reflect the nature of updates being delayed. I think that now we should call performUpdate
directly instead of markUpdated
and make it such that performUpdate
calls into onUpdate
(not the other way around as it is now). Then allow for onUpdate
to be overridden ("onSth" is typically used for things that subclasses can override)
@@ -90,15 +81,7 @@ open class ScreenContainer<T : ScreenFragment>(context: Context?) : ViewGroup(co | |||
get() = mParentScreenFragment != null | |||
|
|||
protected fun markUpdated() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest we get rid of this naming policy now that all updtes are executed immediately. There is no need to a method named "markUpdated" if it does not in fact mark anything and just executes the update. What I think would make the most sense is if we remove markUpdated
and updateIfNeeded
methods, then instead call performUpdate
directly. In turn, performUpdate
should do mAttached
and other checks (that are currently in updateIfNeeded
and all the logic from performUpdate
should be moved to onUpdate
that can be overridden by native stack implementation hence allow for different transactions to be instantiated etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR breaks animations on Android. Check Animations playground in Example/
app.
That's too bad! I was really looking forward this getting merged as it fixed a bunch of odd navigation/animation issues! Does it not work with native navigators? Can something still be done in order to make this work, or is it a dead end? |
@cristianoccazinsp we are working on fixing it right now. |
@cristianoccazinsp can you check if adding this new commit does not introduce any new problems? |
I'm using this for the animation config, for both open and close:
|
@cristianoccazinsp I tried to check the video frame by frame, but I couldn't see anything specific regarding the header. Can you provide the whole reproduction in the form of minimal needed code in e.g. a snack? |
@WoLewicki I will try to build a repro with the example code, but it's very time consuming so it may take me a bit. On the other hand, if you have run the examples and everything seems normal, it's probably an issue on my side with how I've set up the animations. Now that they behave a bit better, perhaps an existing issue is now more noticeable. Lastly, what about the PR for react-navigation? Would that kind of change also help or have you guys discarded it entirely? I believe the two last videos show the issue very clearly. Update: Just tried to reproduce it using the example code and I could not see anything strange with the animations, even when trying to use the same setup, so I'm not sure exactly, perhaps just a visual glitch due to the header content that's barely visible. |
Using the following animation config and StackNavigator (not native stack navigator), I ended up in this situation when combining push and replace (screen cut in half to fit git size): screen-20210903-155918_3.mp4
I think the odd animation I'm seeing is that sometimes the screen appears in front and sometimes behind |
Making the animation even slower, you can see how the first time the screen pops, the previous screen animates very quickly (ignoring the settings, or appearing almost instantly?). Further popping the screen, animates as expected. small.mov
UPDATE: Looks like the screen appearing already almost revealed is due to the use of From https://reactnavigation.org/docs/stack-navigator/#animations
Changing |
PR in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the recent changes the old naming makes more sense as we are actually marking the view to take into the account all the updates later on. I suggest that we restructure the naming as follows:
performUpdate
rename toonScreenChanged
- ScreenContainer implementation of
onScreenChanged
will perform all the fragment manager magic (things that are currently inperformUpdate
and inonUpdate
) - We drop
onUpdate
andperformUpdate
completely - in ScreenStack we override
onScreenChanged
and setmNeedUpdate
there (what we now do inperformUpdate
) - We move logic from
onUpdate
in ScreenStack to a new methodperformUpdates
(we can add "s" at the end of the method name which will suggest that there are a number of changes that can be reflected all at once). Now this method should do all the stuff that's curerntly inperformUpdate
andonUpdate
in ScreenStack. - Rename
performUpdateImmediately
toperformanUpdatesNow
(note there is "s" after "updates")
I think the rest look ok 👍
Added delayed update logic to ScreenContainer in order to resolve issues with too early detached nested navigators when going back from a screen in native-stack with nested different navigators. This change was part of synchronous fragment updates introduced in #1066. Going back like that triggers removeAllScreens code of the nested navigator and it resolved in detaching all of the child screens before the update of native-stack was dispatched, leading to blank screen from the start of navigation.
@WoLewicki , I think this has introduced a bug with react navigation when I'm using the animation config from here https://reactnavigation.org/docs/stack-navigator to simulate a nice slide animation.
Note that the screen that is technically visible, is also not interactive at all as it looks like the one behind (not de-attached) blocks it regardless of the animation config. Steps to reproduce:
Sorry I couldn't catch this earlier, but the use of Also, the screen that overlaps is not the one that was not detached, but rather the one before it. I'm also using
|
Could you provide the full reproduction of it in a form of a snack in an issue so everyone can see it and elaborate? |
Any good starting snack I can use that has all these libs for navigation and screens already set up? |
you can use snack to provide the minimal reproduction code or make a branch with reproduction test in our |
I cannot seem to reproduce the issue with the Example app, still trying to debug to see what's the exact cause of the issue, but since it doesn't happen with the example app, it has to be either a configuration or a conflict with another library. |
@WoLewicki this is really strange. I'm using the exact same code (including Android SDK, libs versions, customizations to java code, disabling hermes, and a bunch of other changes) and I cannot reproduce the bug with the example app, even with nearly 90% of an identical setup. Still debugging, but does something come to mind of what could it be? UPDATE: Finally found it, our project uses appcompat version 1.3.x instead of the default 1.1 from this and other libraries. With appcompat 1.3, the bug happens right away. Will open an issue soon. |
@WoLewicki sorry I keep bothering, but I keep finding tiny issues with this. Did this code change anything that would cause surface events to fire twice? For instance, react-native-camera now fires a surface changed event right after the surface is destroyed when the screen is popped and the component unmounted: https://github.com/react-native-camera/react-native-camera/blob/master/android/src/main/java/com/google/android/cameraview/SurfaceViewPreview.java |
@WoLewicki does this fix this issue: #17 ? |
@hippiejuice it does not change the behavior seen in #17. |
for me, i had to create a work around by playing with the animation configs. and i could say it did work perfectly, but i had to stick with only one type of animation. |
this did fix the performance, but not flickering see this for solution #111 |
Description
Changes fragment commit to synchronous
This PR is based on #1006 (java code rewritten to Kotlin)
Checklist