fix(Android): fix draw ordering in transparent modal & stack nested in tabs interaction #2647
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
Fixes #2167
The exact error mechanism is really convoluted. The gist of it however, and the issue cause lies in the fact
that our drawing / container updating logic worked under implicit (and unspoken of) assumption that draw reordering would not be
applied for the transaction attaching very first screen in the stack. Everything worked correctly until #2019 caused
needsDrawReordeing
to return
true
always whenBuild.VERSION.SDK_INT > 33
- and that means pretty much always in new apps. Previously it returnedfalse
,in particular for the very first screen on stack because no one really sets
stackAnimation
for the very first screen, since it will have no animation anyway(and we might enforce this somewhere in JS code also, I'm not sure now).
This PR restores returning
false
there for first screen on the stack & for any screen that usesanimation: 'none'
.Summary of the error mechanism
Consider following case:
Initially
Screen SA
is rendered. Basically when [isDetachingCurrentScreen
] was set for the very first screen (directly because return value ofneedsDrawReordeing
) and thenwe navigated to other tab
Screen B
- we cause whole stackStack
to be dropped & detached from window. Native callbackonDetachedFromWindow
gets called inScreenContainer
,we detach every fragment and subview (to prevent whole different class of bugs) causing
removeView
callbacks inScreenStack
, leading toreverseLastTwoChildren
flag being set totrue
. When we then change tab back toScreen SA
inStack
the drawing works as normal, because we have only one child. On navigation to
Screen TM
(transparent modal) value of thereverseLastTwoChildren
flag causes the views to being drawnin wrong order - transparent modal first and
Screen SA
second. In case of nottransparent
presentation there is no issue, becauseScreen SA
would get detached.Changes
Added param to
needsDrawReordeing
method informing of actual stack animation in use (in case of first screen we always set it tonone
).When there is no animation for the disappearing screen - there is no need to change the draw ordering. Added appropriate code comment for the future.
Test code and steps to reproduce
Test2167
Checklist