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] Do not throw on empty registered headless task #24671

Closed
wants to merge 2 commits into from
Closed

[Android] Do not throw on empty registered headless task #24671

wants to merge 2 commits into from

Conversation

timwangdev
Copy link
Contributor

@timwangdev timwangdev commented May 1, 2019

Summary

Start a HeadlessJsTaskService on Android without registered is dangerous on apps because HeadlessJsTaskService will acquire a PARTIAL_WAKE_LOCK, without calling onHeadlessJsTaskFinish this lock won't release until timeout(if exist). This lock will prevent the android device from sleeping.

Although on JS will throw an error if no headless tasks registered, but it's hard to notice while app in the background. No visual information is displayed.

This PR will log a warning instead of Error, and just mark the task to finished on native if nothing registered in order to release the wake lock.

Changelog

[Android] [Fixed] - Fix unexpected PARTIAL_WAKE_LOCK when no headless tasks registered.

Test Plan

WIll add later.

@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 May 1, 2019
Copy link

@analysis-bot analysis-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code analysis results:

  • eslint found some issues. Run yarn lint --fix to automatically fix problems.

Libraries/ReactNative/AppRegistry.js Outdated Show resolved Hide resolved
@timwangdev timwangdev changed the title [Android] Not throw on empty registered headless task [Android] Do not throw on empty registered headless task May 1, 2019
Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thank you.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @timwangdev in bdb1d43.

When will my fix make it into a release? | Upcoming Releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: AppRegistry CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants