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

fix: blurView integration with ScreenStack #1406

Merged
merged 2 commits into from
Apr 25, 2022

Conversation

WoLewicki
Copy link
Member

Description

BlurView sometimes calls draw method of the app's rootView, causing unexpected behavior in our library. Since BlurView is a child of ScreenStack in the crashing example, calling op.draw() calls BlurView onDraw method, which then sometimes calls draw method in app's rootView. It results in visiting the drawAndRelease method again. The important thing is drawingOps.indices makes IntRange under the hood, which is then used in next loop calls. At the same time, after the most nested for loop ends, it clears the drawingOps, but this change is not visible in the former for since it just loops over IntRange created before. This results in indexOutOfBounds crash when we try to obtain an op from empty drawingOps. As an addition, If we didn't use indices, but for (op in drawingOps), it would result in ConcurrentModificationException.

Current fix makes a copy of drawingOps which is then used in for loop, and clearing the drawingOps so the nested calls cannot change the original one.

Test code and steps to reproduce

https://github.com/mjm918/RNScreensBlurViewCrash-Repro/blob/master/AppCrash.tsx

Checklist

mjm918 pushed a commit to mjm918/RNScreensBlurViewCrash-Repro that referenced this pull request Apr 14, 2022
software-mansion/react-native-screens#1406

● App will not crash if there is single blurview
● In first screen there is 1 blurview and the app did not crash
● In second screen there are multiple blurview and app crashed with exception `java.lang.IndexOutOfBoundsException: Index: 1, Size: 0`
● As suggested, I added `android:hardwareAccelerated="true"` in Manifest but the crash still persist
@WoLewicki WoLewicki merged commit 9b4e50e into main Apr 25, 2022
@WoLewicki WoLewicki deleted the @wolewicki/fix-blurview-integration branch April 25, 2022 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recording currently in progress - missing #endRecording() call
1 participant