Title: feat(worker): accept platform options under android, deprecate androidPriority by edusperoni · Pull Request #2041 · NativeScript/android · GitHub
Open Graph Title: feat(worker): accept platform options under android, deprecate androidPriority by edusperoni · Pull Request #2041 · NativeScript/android
X Title: feat(worker): accept platform options under android, deprecate androidPriority by edusperoni · Pull Request #2041 · NativeScript/android
Description: What changed new Worker(url, options) now takes its Android-specific settings under an android namespace object, so future platform options have a place to live instead of accumulating as androidSomething keys on the top level. const worker = new Worker("./worker.js", { android: { priority: "lowest" }, }); android.priority accepts the camelCase android.os.Process.THREAD_PRIORITY_* names — "lowest", "background", "lessFavorable", "default", "moreFavorable", "foreground", "display", "urgentDisplay", "video", "audio", "urgentAudio" — or a raw nice value clamped to [-20, 19], and is applied with Process.setThreadPriority on the worker thread. Deprecation options.androidPriority keeps working unchanged. Passing it logs a one-time per-process warning pointing at android.priority. When both keys are present, android.priority wins and the legacy value is not validated. Validation Input Result android present and not an object (null counts as absent, as for a WebIDL dictionary) TypeError android.priority neither a recognized name nor a number TypeError naming "android.priority" android.priority an unknown string TypeError naming "android.priority" android.priority a number outside [-20, 19] clamped unknown keys inside android ignored (forward compatibility) androidPriority with an unusable value unchanged (throws, as before) The thrown value is a genuine TypeError instance, so e instanceof TypeError holds in JS — NativeScriptException gained an overload that carries an already-built JS error value through ReThrowToV8 unchanged. Along the way, an options getter that throws now stops construction: the ->Get(...).ToLocal(...) result was folded into the "no option given" branch, so the pending exception was dropped and the worker started at the default priority. Verification ./gradlew runtestsAndVerifyResults -Pabis=arm64-v8a, Debug, API 33 emulator. Metric Count tests 1223 failures 0 errors 0 skipped 4 That is the 1207-test baseline plus the 16 specs added here; the skips are unchanged. Mirrors NativeScript/ios#470. Deviations from the iOS PR Android's priority surface is a nice value, not NSQualityOfService, so android.priority also accepts numbers and the "must be a string" rejection becomes "neither a recognized name nor a number". No std::optional sentinel fix is needed: Android's "unset" default is THREAD_PRIORITY_BACKGROUND (10), which no sentinel collides with. The specs read the thread's nice value back with android.os.Process.getThreadPriority(android.os.Process.myTid()) from inside the worker. Only the non-negative names are asserted exactly — lowering a thread's nice value needs a privilege the app may not hold — with the negative names covered by starting a worker instead. Follow-ups @nativescript/core typings for WorkerOptions need android?: { priority?: ... }, with androidPriority marked @deprecated. A stacked PR adds resourceLimits. Summary by CodeRabbit New Features Added support for configuring Android worker thread priority with named or numeric values. Priority settings now support negative values and safe range clamping. Nested Android options take precedence over legacy priority settings. Bug Fixes Invalid priority values now produce clear JavaScript TypeError errors. Legacy priority configuration remains supported with a deprecation notice. Errors encountered while reading worker options are now preserved and reported correctly.
Open Graph Description: What changed new Worker(url, options) now takes its Android-specific settings under an android namespace object, so future platform options have a place to live instead of accumulating as androidSo...
X Description: What changed new Worker(url, options) now takes its Android-specific settings under an android namespace object, so future platform options have a place to live instead of accumulating as androidSo...
Opengraph URL: https://github.com/NativeScript/android/pull/2041
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:366b2284-c953-0ab5-f0c5-ae6116dc4687 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D148:3F4253:1820199:2014753:6B014908 |
| html-safe-nonce | e52c52e26cb81752f3e1a0198995e8800ebf44be9e9905ff078ad0b0502cab65 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTQ4OjNGNDI1MzoxODIwMTk5OjIwMTQ3NTM6NkIwMTQ5MDgiLCJ2aXNpdG9yX2lkIjoiMjQ0NDc1MjU2OTg3MzAyNTI4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 018c1ecc96780b6394732c7871608d421ce467c7a0cf12beefdc258ed39ce30f |
| hovercard-subject-tag | pull_request:4509659022 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/android/pull/2041/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | What changed new Worker(url, options) now takes its Android-specific settings under an android namespace object, so future platform options have a place to live instead of accumulating as androidSo... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/android git https://github.com/NativeScript/android.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 29137950 |
| octolytics-dimension-repository_nwo | NativeScript/android |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 29137950 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/android |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width