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

[Android] Add onUserLeaveHint support to ReactActivityDelegate #43658

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

behenate
Copy link
Contributor

@behenate behenate commented Mar 26, 2024

Summary:

This is a resubmission of the previous PRs. We are trying to figure out why it causes crashes in some apps.

This PR adds onUserLeaveHint support into the ReactActivityDelegate. It allows modules to receive an event every time user moves the app into the background. This is slightly different than onPause - it's called only when the user intentionally moves the app into the background, e.g. when receiving a call onPause should be called but onUserLeaveHint shouldn't.

This feature is especially useful for libraries implementing features like Picture in Picture (PiP), where using onUserLeaveHint is the recommended way of auto-entering PiP for android < 12.

Changelog:

[ANDROID] [ADDED] - Added onUserLeaveHint support into ReactActivityDelegate

Test Plan:

Tested in the rn-tester app - callbacks are correctly called on both old and new architecture.

@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 Mar 26, 2024
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Mar 26, 2024
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 18,073,881 -376,780
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 21,440,617 -375,017
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 6d0f72b
Branch: main

@behenate
Copy link
Contributor Author

behenate commented Apr 4, 2024

@cortinico Any updates on the source of the crashes?

@cortinico
Copy link
Contributor

@cortinico Any updates on the source of the crashes?

I haven't had the time to test again sorry. Hopefully I should have an answer by next week

@facebook-github-bot
Copy link
Contributor

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

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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants