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

Resolve android crash on display modal #35380

Closed
wants to merge 1 commit into from

Conversation

alpha0010
Copy link
Contributor

Summary

From exception logging, found crashes due to Attempt to invoke virtual method 'int android.view.ViewGroup.getChildCount()' on a null object reference. Tracing through the stack, it appears the constructor for ViewGroup conditionally calls initializeScrollbarsInternal(), which in turn calls getChildCount(). However ReactModalHostView overrides getChildCount(), so getChildCount() is called before ReactModalHostView constructor completes, resulting in null reference when accessing mHostView from getChildCount().

Changelog

[Android] [Fixed] - Fix crash on initialize modal

Test Plan

In the rn-tester project, display a modal.

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,102,234 -29
android hermes armeabi-v7a 6,471,420 -24
android hermes x86 7,519,586 -13
android hermes x86_64 7,378,007 -19
android jsc arm64-v8a 8,967,066 +33
android jsc armeabi-v7a 7,697,914 +37
android jsc x86 9,029,227 +32
android jsc x86_64 9,507,042 +32

Base commit: 04c286c
Branch: main

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 3681df2
Branch: main

@pull-bot
Copy link

PR build artifact for 24da660 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

PR build artifact for 24da660 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 17, 2022
@facebook-github-bot
Copy link
Contributor

@ryancat has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

kelset pushed a commit that referenced this pull request Nov 22, 2022
Summary:
From exception logging, found crashes due to `Attempt to invoke virtual method 'int android.view.ViewGroup.getChildCount()' on a null object reference`. Tracing through the stack, it appears the constructor for `ViewGroup` conditionally calls `initializeScrollbarsInternal()`, which in turn calls `getChildCount()`.  However `ReactModalHostView` overrides `getChildCount()`, so `getChildCount()` is called before `ReactModalHostView` constructor completes, resulting in null reference when accessing `mHostView` from `getChildCount()`.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Fix crash on initialize modal

Pull Request resolved: #35380

Test Plan: In the rn-tester project, display a modal.

Reviewed By: javache, cipolleschi

Differential Revision: D41392235

Pulled By: ryancat

fbshipit-source-id: ce78e4d458ad41769e78139ea0a8a038384e830d
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
From exception logging, found crashes due to `Attempt to invoke virtual method 'int android.view.ViewGroup.getChildCount()' on a null object reference`. Tracing through the stack, it appears the constructor for `ViewGroup` conditionally calls `initializeScrollbarsInternal()`, which in turn calls `getChildCount()`.  However `ReactModalHostView` overrides `getChildCount()`, so `getChildCount()` is called before `ReactModalHostView` constructor completes, resulting in null reference when accessing `mHostView` from `getChildCount()`.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Fix crash on initialize modal

Pull Request resolved: facebook#35380

Test Plan: In the rn-tester project, display a modal.

Reviewed By: javache, cipolleschi

Differential Revision: D41392235

Pulled By: ryancat

fbshipit-source-id: ce78e4d458ad41769e78139ea0a8a038384e830d
@cipolleschi cipolleschi mentioned this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants