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: Crash index out of bounds when open multiple modal the second time #340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rifansyah
Copy link

@rifansyah rifansyah commented Apr 22, 2021

What is going on?

We got crash when having a multiple modal, then open the top modal a second time.

The crash error:

java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
    at ...

Level: {crash}

How to reproduce?

Condition

  • not using coverScreen props
  • having a multiple modal shown

Step

open the top modal, close it, and open it again

Caused by

when the modal is not visible, the library will only return View without zIndex props, and when it's visible, it'll return a view with a zIndex style props.

I'm not sure about the cause, but because the js side and native side is asynchronously connected, then maybe when the modal is about to be opened, the native side is trying to reOrder the view with zIndex (at com.facebook.react.uimanager.ViewGroupDrawingOrderHelper.getChildDrawingOrder) while the View with zIndex props is not ready yet. That's why we got java.lang.ArrayIndexOutOfBoundsException: length=3; index=3

Resolved by

We return a View with the same zIndex (use styles.transparent) when the modal is not visible, in this way, the view group will have the same number of view with a zIndex props to prevent a not ready view whether it's visible or not.

@rifansyah rifansyah mentioned this pull request Apr 22, 2021
@kbanashek
Copy link

kbanashek commented May 12, 2022

This should be the accepted answer, thank you for providing this! @rifansyah

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.

2 participants