Closed kross-italk closed 2 months ago
:warning: | Newer Version of React Native is Available! |
---|---|
:information_source: | You are on a supported minor version, but it looks like there's a newer patch available - 0.73.9. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |
:warning: | Missing Reproducible Example |
---|---|
:information_source: | We could not detect a reproducible example in your issue report. Please provide either:
|
:warning: | Missing Reproducible Example |
---|---|
:information_source: | We could not detect a reproducible example in your issue report. Please provide either:
|
:warning: | Newer Version of React Native is Available! |
---|---|
:information_source: | You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |
And listen, pushing everyone in the community away with an auto-close bot isn't helping.
And listen, pushing everyone in the community away with an auto-close bot isn't helping.
That's because this is an issue tracker only. It's not the right spot for questions/discussions. The best place is here https://github.com/react-native-community/discussions-and-proposals (there is even a button in https://github.com/facebook/react-native/issues/new/choose).
To answer your question: we'll most likely deprecate and remove Headless JS in a future version. We'll open a discussion in the coming months to collect community feedback from it, but the reality is that is not an API we'd recommend.
We're not using it internally at Meta, and it's backed by an Android Service
which is a bad choice in 2024 for background execution.
The documentation should also be updated to mention to don't use this API anymore.
The alternative would be to update Headless JS API to depend on WorkManager
or JobScheduler
but we don't have capacity at the moment to do this work. A community contribution would be more than welcome in this sense.
Description
After going through the implementation, HeadlessJS is poorly advertised. By its name sake, one would expect "Headless" and "Background" to be synonmous. That doesn't appear to be the case:
https://github.com/facebook/react-native/issues/15915 https://github.com/facebook/react-native/issues/27835 https://github.com/facebook/react-native/issues/43950 https://github.com/facebook/react-native/issues/36493
Headless JS tasks have to be started from the Main UI thread, and when the app is put in the background (but left running) the tasks stop. This is next to useless, I could always have asyncrously scheduled my jobs in the main JS conext while the app was forgrounded. The very existence of the "Crash in foreground" being the default suggests this isn't going to be considered.
The documentation was very rough and I had to cobble together various open source repos that demonstrate using it.
How is one expected to make a real background service using Headless JS? Is there any future to this code, or has it gone stale?
Steps to reproduce
React Native Version
0.73.6
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer