Skip to content

Android Runtime Updates and One Shared Engine Layer - #67

Draft
ammarahm-ed wants to merge 57 commits into
refactorfrom
port/android-updates-on-refactor
Draft

Android Runtime Updates and One Shared Engine Layer#67
ammarahm-ed wants to merge 57 commits into
refactorfrom
port/android-updates-on-refactor

Conversation

@ammarahm-ed

@ammarahm-ed ammarahm-ed commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Update the android layer to latest changes from https://github.com/NativeScript/napi-android and in doing so collapses the two per-platform engine layers into a single unified layer.

Apple and Android now share a single backend per engine rather than keeping parallel copies that drift, run against the same engine versions, and fetch their prebuilt binaries on demand instead of carrying them in the repository.

  • NativeScript/napi/<engine>/ now includes only the jsr layer.
  • vendor/ has all engine related headers, sources, napi bindings etc shared by both Apple & Android

What changed

One engine layer for both platforms

  • V8, JSC, QuickJS and Hermes each collapse to a single backend shared by Apple and Android, instead of a copy per platform
  • Each engine's Node-API layer moved under a common vendor location, and the vendored Hermes and V8 headers are shared rather than forked
  • Hermes updated, with Apple and Android now built against the same Hermes version from the same release. Right now it picks the updated release from https://github.com/ammarahm-ed/build-hermes/releases/tag/build-d207b501aecb. It includes a single host_objects patch for napi android currently.
  • Hermes serves both Node-API ABIs from one runtime
  • QuickJS-NG is now the QuickJS engine on both platforms, from a patched vendored tree; the Bellard tree and its bundled allocator are removed, and the old engine name is kept as an alias so existing builds keep working. mimalloc is also removed as it stopped making a performance difference in latest quickjs engines.
  • V8 moves to the 14.9 API, and the two long-dead V8 versions are dropped. Using https://github.com/ammarahm-ed/v8-buildscripts/releases/tag/v8-14.9.207.39-5 which should be merged upstream
  • Engine binaries and headers are fetched on demand rather than committed, which takes several hundred megabytes out of the repository

Android runtime

  • Java runtime layer, JNI Node-API interop, runtime core, native workers and the inspector
  • Engine support for V8, JSC, Hermes, QuickJS and PrimJS, with host object support added or rewritten per engine
  • Test-app suites and build tools, and Gradle/CMake wiring for all of it
  • Bytecode compiler toolchain is added that compiles bytecode compiler for hermes, quickjs & primjs, it should be moved to main workflows dir I think though. andorid/.github should be removed.

URL

  • Ada 3.3.0, with URLPattern and URLSearchParams brought up to spec
  • The URLSearchParams iterator now has a single owner and derives its state from the receiver, fixing iteration on both platforms

Runtime correctness

  • Hermes: native callbacks arriving on another thread take the runtime lock before entering the VM, rather than entering it unguarded
  • Hermes: a JavaScript exception can no longer escape the microtask drain into Objective-C
  • JavaScriptCore: the context map is guarded against concurrent access from workers
  • JavaScriptCore: an explicit collection is now a real synchronous one on Android
  • Timers get unique ids, so the stress specs stop timing out

Verified

  • Five Android engines on device: no failures
  • Four macOS engines and the iOS simulator: no failures

Notes for reviewers

  • Sharing one backend per engine means a change to any of them now lands on both platforms at once. That is the point, but it does mean an Apple-only change deserves an Android run, and the reverse.
  • Only one engine is exercised on macOS in CI today. Widening that would catch engine-specific regressions that a single-engine run cannot.

NAPI_GUARD now logs the failing call, NAPI_CALLBACK_BEGIN_VARGS_FAST is added,
and napi_runtime becomes jsr_ns_runtime across every JSR implementation.

(cherry picked from commit a09460e)
…adapter

The vendored trees become submodules with local changes carried as patches, and
the adapter propagates every napi_status and stops clobbering pending errors.

(cherry picked from commit c3d6419)
Replaces the adapter with the upstream-shaped one, fixes the napi_post_finalizer
argument order, and drains queued jobs only once the stack unwinds.

(cherry picked from commit e77e7b1)
Moves to libJavaScriptCore.so, handles symbol-keyed properties, and installs the
unhandled promise rejection tracker.

(cherry picked from commit ff97a6d)
Replaces the previous implementation with the one from the updates branch, and
carries the accompanying inspector changes.

(cherry picked from commit 65413f8)
Apple keeps the C++ createNodeApiEnv hook; Android uses the upstream C ABI
behind __ANDROID__, which brings it bytecode support.

(cherry picked from commit e28db2c)
Adds the finalizer queue, @CriticalNative/@fastNative registration and
NAPI_GUARD coverage, keeping the napi-ios constructor and ObjectManager
semantics.

(cherry picked from commit bb3c5d1)
Workers and messaging move from Java into C++, timers order against the Java
MessageQueue, and the inspector serves source maps and worker isolates.

(cherry picked from commit 81222af)
keys/values/entries return real iterators and walk entries positionally, the
constructor accepts the sequence and record init forms, and URLPattern is added.

(cherry picked from commit 6e43706)
DexFactory injects proxies into the app class loader, worker threading moves to
C++, and TimerHandler orders timers through the MessageQueue.

(cherry picked from commit 91fa40b)
All engines compile as C++20, Hermes .so files are selected by build type, and
every test-app prebuilt now goes through Git LFS.

(cherry picked from commit 4e553ef)
New URLPattern/URLSearchParams/timer/worker specs, an intent-selected launch
mode for MyActivity, and jsparser/metadata-generator fixes.

(cherry picked from commit a270791)
Adds tools/bytecode-compiler, its build workflow and docs; build.js enables host
objects by default behind a --disable-host-objects escape hatch.

(cherry picked from commit 1f725a2)
Two Apple-side consumers pulled the handle in transitively and were left with no
declaration after the rename.

(cherry picked from commit fefaa8c)
…te status

Ports get/getAll/has/delete/append/set onto the WHATWG behaviour, corrects
BuildFromSequence and the null init form, and drops a redeclared `status`.

(cherry picked from commit 43b053a)
The port deleted it as an Android file, but in napi-ios it is the shared header.

(cherry picked from commit 232cfec)
Restores hermes/napi/node_api*.h, and scopes NS_BYTECODE_ENABLED with
target_compile_definitions instead of add_compile_definitions.

(cherry picked from commit 5cdee09)
Regenerates both patch files with the WeakRef keepalive mechanism (and the
VERSION-file drop), and makes setup.js genuinely idempotent.

(cherry picked from commit 55d372b)
pickFirst the libc++_shared.so/libfbjni.so copies fbjni duplicates, and
null-check castInterface<IHermes> instead of segfaulting.

(cherry picked from commit 02c2b29)
Removes the 244 vendored engine files that `git add` staged over the gitlinks.

(cherry picked from commit 9ac85a8)
Apple's headers add a createNodeApiEnv vtable slot that the prebuilt
libhermesvm.so does not have, which crashed the runtime at startup.

(cherry picked from commit d3fabc2)
The external now owns and deletes IterState; the redundant napi_add_finalizer
was double-freeing it and crashing QuickJS-NG.

(cherry picked from commit 512ebab)
Fixes 11 PrimJS "Illegal invocation" failures: the brand check relied on a
pointer surviving a round trip through two unrelated Node-API mechanisms.

(cherry picked from commit ec318b9)
… specs

Guard the NAPI_VERSION redefinitions, iterate GetAll as uint32_t, and assert the
WHATWG iterator/null behaviour the Android suite already expects.

(cherry picked from commit 7d6a01a)
…sync

Map the two dropped custom status codes onto their upstream equivalents and cast
at the escapable-scope boundary, the way the Android backend already does.

(cherry picked from commit f54acac)
(cherry picked from commit 576719d)
(cherry picked from commit daad6082818715b18bca7f01f24681cb5db8473c)
(cherry picked from commit 516f3220a7a0d26fb6c0520c28d5a84fb44fd289)
…away

(cherry picked from commit 869f7dbf1fd823dc425183e71f79f22cf5bd2d7d)
(cherry picked from commit c92f338dab01e793049f22a3ee5b0c46ba54e830)
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a34ca6ba-aaf0-492c-904d-046fb8270d29

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ammarahm-ed ammarahm-ed changed the title Port/android updates on refactor Android Runtime Updates and One Shared Engline Layer Aug 16, 2026
@ammarahm-ed ammarahm-ed changed the title Android Runtime Updates and One Shared Engline Layer Android Runtime Updates and One Shared Engine Layer Aug 16, 2026
@ammarahm-ed ammarahm-ed mentioned this pull request Aug 16, 2026
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant