Skip to content

JS port: isSupported() must answer false for an unbound native interface - #5515

Merged
shai-almog merged 1 commit into
masterfrom
fix/js-native-interface-issupported
Aug 4, 2026
Merged

JS port: isSupported() must answer false for an unbound native interface#5515
shai-almog merged 1 commit into
masterfrom
fix/js-native-interface-issupported

Conversation

@shai-almog

@shai-almog shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes #5512.

The problem

NativeLookup.create() can never return null on the JavaScript port. The builder scans the app for every NativeInterface subtype and generates + registers an <Iface>Impl for each one (JavaScriptBuilder.generateNativeInterfaceImpls / writeLauncher), whether or not a JS implementation ships in the bundle. On iOS/Android the same guard works because a missing native implementation means no *Impl class at all, so create() returns null.

That makes isSupported() the developer's only "is this bound here?" signal — and it was throwing rather than answering. The generated isSupported() delegated blindly to the host bridge, which rejected an unregistered interface with No native interface implementation registered for <iface>; resolveHostCall turns a rejection into generator.throw(...), so it surfaced in Java as a RuntimeException thrown straight out of the standard guard:

NativeInterface s = NativeLookup.create(X.class);
if (s != null && s.isSupported()) { ... }

Note the generated JS stub template itself already defaults isSupported_ to callback.complete(false) (StubGenerator.generateJavaScriptFile) — the missing-stub path just never got that far.

The fix

Two coordinated changes:

  • browser_bridge.js resolves false for the isSupported_ key when the interface is absent from cn1_native_interfaces, or when the registered stub defines no isSupported (with a once-per-interface console warning). Every other method still rejects — calling an unimplemented native is a genuine bug and must stay loud.
  • The generated <Iface>Impl wraps its isSupported() bridge call in a try/catch that degrades to false, so the contract holds even if the call fails for another reason. The impl-source generation moved into a package-visible nativeInterfaceImplSource(Class) so it can be asserted without running a build.

Tests

  • JavaScriptNativeInterfaceBridgeTest drives browser_bridge.js's native-interface dispatch directly in node, with the page boot suppressed (a document.readyState of "loading" makes the bridge wait for a DOMContentLoaded that never fires). Verified to fail against the pre-fix bridge: unregistered isSupported_ rejected with the reported message, and a stub without isSupported_ rejected too.
  • JavaScriptBuilderNativeInterfaceTest asserts the generated impl guards isSupported() and only isSupported().

Companion PR

The daemon's ParparVMJavascriptBuilder carries the twin builder change: codenameone/BuildDaemon#170

🤖 Generated with Claude Code

NativeLookup.create() can never return null on the JavaScript port -- the
builder generates and registers an <Iface>Impl for EVERY NativeInterface it
finds in the app, whether or not a JS implementation ships with the bundle.
That makes isSupported() the developer's only "is this bound here?" signal,
and it was throwing rather than answering: the host bridge rejected the call
with "No native interface implementation registered for <iface>", which
surfaced in the worker as a RuntimeException out of the standard

    NativeLookup.create(X.class) != null && x.isSupported()

guard. On iOS/Android the same guard works because a missing native impl
means no *Impl class at all, so create() returns null.

Two coordinated changes:

* browser_bridge.js resolves false for the isSupported_ key when the
  interface is absent from cn1_native_interfaces, or when the registered
  stub defines no isSupported (warning once per interface). Every other
  method still rejects -- calling an unimplemented native is a genuine bug
  and must stay loud.
* The generated <Iface>Impl wraps its isSupported() bridge call in a
  try/catch that degrades to false, so the contract holds even if the call
  fails for some other reason.

Tests: a node harness drives browser_bridge.js's dispatch directly with the
page boot suppressed, and the generated-impl source is asserted without
running a build.

Fixes #5512

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 4, 2026 01:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes JavaScript-port NativeInterface.isSupported() behavior so that “missing/unbound” native interface implementations reliably answer false instead of throwing, restoring the standard NativeLookup.create(..) != null && ni.isSupported() guard semantics on the JS port.

Changes:

  • Update browser_bridge.js native-interface dispatch to resolve false for isSupported_ when an interface (or its isSupported_) is not registered, while keeping other methods rejecting loudly.
  • Update JavaScript builder codegen so the generated <Iface>Impl.isSupported() wraps the bridge call in a try/catch and degrades to false on failure; expose impl source generation for test assertions.
  • Add unit tests for both the bridge dispatch behavior (Node-driven) and the builder codegen contract.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
vm/tests/src/test/java/com/codename1/tools/translator/JavaScriptNativeInterfaceBridgeTest.java Adds Node-based tests asserting isSupported_ resolves false for unbound/partial interfaces, while other methods still reject.
vm/ByteCodeTranslator/src/javascript/browser_bridge.js Implements special-case isSupported_ fallback to false when interface or isSupported_ implementation is missing.
maven/codenameone-maven-plugin/src/test/java/com/codename1/builders/JavaScriptBuilderNativeInterfaceTest.java Adds tests verifying generated impl guards only isSupported() and preserves failure propagation elsewhere.
maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/JavaScriptBuilder.java Refactors native-impl source generation for testability and adds guarded isSupported() generation.
Suppressed comments (1)

maven/codenameone-maven-plugin/src/test/java/com/codename1/builders/JavaScriptBuilderNativeInterfaceTest.java:63

  • This test counts occurrences of catch (Throwable) to ensure only isSupported() swallows bridge failures. If the generated impl is updated to catch a narrower type (recommended), update the counted substring so the assertion remains accurate.
        assertEquals(1, countOccurrences(source, "catch (Throwable"),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sb.append(" try {\n");
sb.append(" return com.codename1.impl.platform.js.NativeInterfaceBridge.callBoolean(__NI, \"")
.append(methodKey).append("\", new Object[0]);\n");
sb.append(" } catch (Throwable __t) {\n");
"Generated impl should implement isSupported(). source=" + source);
assertTrue(source.contains("callBoolean(__NI, \"isSupported_\", new Object[0])"),
"isSupported() should still ask the host bridge first. source=" + source);
assertTrue(source.contains("} catch (Throwable __t) {") && source.contains("return false;"),
// interface (issue #5512). Every other method still rejects -- calling an
// unimplemented native is a genuine bug and must stay loud.
var NI_IS_SUPPORTED = 'isSupported_';
var niUnboundWarned = {};
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 417 total, 0 failed, 14 skipped

Benchmark Results

  • Execution Time: 24427 ms

  • Hotspots (Top 20 sampled methods):

    • 19.29% java.util.ArrayList.indexOf (388 samples)
    • 6.71% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (135 samples)
    • 4.48% com.codename1.tools.translator.BytecodeMethod.equals (90 samples)
    • 3.58% java.lang.StringBuilder.append (72 samples)
    • 2.98% com.codename1.tools.translator.Parser.cn1EnsureSubclassIndex (60 samples)
    • 2.98% com.codename1.tools.translator.ByteCodeClass.hasDeclaredMethod (60 samples)
    • 2.83% org.objectweb.asm.tree.analysis.Analyzer.analyze (57 samples)
    • 2.44% com.codename1.tools.translator.bytecodes.Invoke.findMethodUp (49 samples)
    • 2.39% com.codename1.tools.translator.BytecodeMethod.optimize (48 samples)
    • 2.09% com.codename1.tools.translator.BytecodeMethod.appendMethodC (42 samples)
    • 1.89% java.lang.String.equals (38 samples)
    • 1.84% com.codename1.tools.translator.Parser.classIndex (37 samples)
    • 1.39% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (28 samples)
    • 1.39% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (28 samples)
    • 1.39% org.objectweb.asm.ClassReader.readCode (28 samples)
    • 1.34% com.codename1.tools.translator.bytecodes.Invoke.resolveDirectTarget (27 samples)
    • 1.19% org.objectweb.asm.tree.analysis.Analyzer.findSubroutine (24 samples)
    • 1.19% java.lang.StringCoding.encode (24 samples)
    • 0.94% java.util.HashMap.hash (19 samples)
    • 0.90% java.lang.System.identityHashCode (18 samples)
  • ⚠️ Coverage report not generated.

Static Analysis

  • ✅ SpotBugs: no findings (report was not generated by the build).
  • ⚠️ PMD report not generated.
  • ⚠️ Checkstyle report not generated.

Generated automatically by the PR CI workflow.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ByteCodeTranslator: 0 findings (no issues)
    • android: 0 findings (no issues)
    • codenameone-maven-plugin: 0 findings (no issues)
    • core-unittests: 0 findings (no issues)
    • ios: 0 findings (no issues)
  • PMD: 0 findings (no issues) [Report archive]
  • Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 matched.
Native Windows port (x64 / Intel-AMD): full hellocodenameone screenshot suite rendered offscreen with Direct2D/DirectWrite, plus the real benchmarks (base64 native/CN1/SIMD, image createMask/applyMask/modifyAlpha/PNG/JPEG, SSE2 SIMD kernels). Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 61ms / native 4ms = 15.2x speedup
SIMD float-mul (64K x300) java 65ms / native 4ms = 16.2x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 192.000 ms
Base64 CN1 decode 128.000 ms
Base64 SIMD encode 100.000 ms
Base64 encode ratio (SIMD/CN1) 0.521x (47.9% faster)
Base64 SIMD decode 90.000 ms
Base64 decode ratio (SIMD/CN1) 0.703x (29.7% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 26.000 ms
Image createMask (SIMD on) 19.000 ms
Image createMask ratio (SIMD on/off) 0.731x (26.9% faster)
Image applyMask (SIMD off) 40.000 ms
Image applyMask (SIMD on) 157.000 ms
Image applyMask ratio (SIMD on/off) 3.925x (292.5% slower)
Image modifyAlpha (SIMD off) 39.000 ms
Image modifyAlpha (SIMD on) 27.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.692x (30.8% faster)
Image modifyAlpha removeColor (SIMD off) 38.000 ms
Image modifyAlpha removeColor (SIMD on) 29.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.763x (23.7% faster)

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 151 screenshots: 151 matched.

Native Android coverage

  • 📊 Line coverage: 7.85% (7605/96841 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 7.72% (39610/513127), branch 2.81% (1364/48627), complexity 3.16% (1647/52177), method 4.87% (1345/27595), class 9.98% (367/3679)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6367 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.ClassReader – 0.00% (0/1524 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1187 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.MethodWriter – 0.00% (0/922 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/736 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • okio.okio.Buffer – 0.00% (0/687 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/625 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.Frame – 0.00% (0/570 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 7.85% (7605/96841 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 7.72% (39610/513127), branch 2.81% (1364/48627), complexity 3.16% (1647/52177), method 4.87% (1345/27595), class 9.98% (367/3679)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6367 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.ClassReader – 0.00% (0/1524 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1187 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.MethodWriter – 0.00% (0/922 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/736 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • okio.okio.Buffer – 0.00% (0/687 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/625 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.Frame – 0.00% (0/570 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend scalar fallback (no native SIMD)
SIMD int-add (64K x300) java 157ms / native 148ms = 1.0x speedup
SIMD float-mul (64K x300) java 123ms / native 98ms = 1.2x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 94.000 ms
Base64 CN1 decode 90.000 ms
Base64 native encode 342.000 ms
Base64 encode ratio (CN1/native) 0.275x (72.5% faster)
Base64 native decode 305.000 ms
Base64 decode ratio (CN1/native) 0.295x (70.5% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 matched.
Native Windows port, REAL shipping pipeline: the hellocodenameone screenshot suite rendered by a binary CROSS-COMPILED on Linux (clang-cl + xwin, WebView2 linked) and RUN on a Windows x64 runner. Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 69ms / native 4ms = 17.2x speedup
SIMD float-mul (64K x300) java 58ms / native 4ms = 14.5x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 201.000 ms
Base64 CN1 decode 126.000 ms
Base64 SIMD encode 100.000 ms
Base64 encode ratio (SIMD/CN1) 0.498x (50.2% faster)
Base64 SIMD decode 91.000 ms
Base64 decode ratio (SIMD/CN1) 0.722x (27.8% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 32.000 ms
Image createMask (SIMD on) 25.000 ms
Image createMask ratio (SIMD on/off) 0.781x (21.9% faster)
Image applyMask (SIMD off) 58.000 ms
Image applyMask (SIMD on) 34.000 ms
Image applyMask ratio (SIMD on/off) 0.586x (41.4% faster)
Image modifyAlpha (SIMD off) 225.000 ms
Image modifyAlpha (SIMD on) 51.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.227x (77.3% faster)
Image modifyAlpha removeColor (SIMD off) 57.000 ms
Image modifyAlpha removeColor (SIMD on) 31.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.544x (45.6% faster)

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 147 screenshots: 147 matched.
Native Linux port (x64), GTK3/Cairo/Pango, ParparVM bytecode-to-C (no JVM): the hellocodenameone screenshot suite rendered by a native ELF built + run on the GitHub x64 runner. Baseline: scripts/linux/screenshots.

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 147 screenshots: 147 matched.
Native Linux port (arm64), GTK3/Cairo/Pango, ParparVM bytecode-to-C (no JVM): the hellocodenameone screenshot suite rendered by a native ELF built + run on the GitHub arm64 runner. Baseline: scripts/linux/screenshots-arm.

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 matched.
Native Windows port (arm64 / Apple Silicon - Arm): full hellocodenameone screenshot suite rendered offscreen with Direct2D/DirectWrite, plus the real benchmarks (base64 native/CN1/SIMD, image createMask/applyMask/modifyAlpha/PNG/JPEG, NEON SIMD kernels). Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 57ms / native 4ms = 14.2x speedup
SIMD float-mul (64K x300) java 54ms / native 3ms = 18.0x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 246.000 ms
Base64 CN1 decode 127.000 ms
Base64 SIMD encode 65.000 ms
Base64 encode ratio (SIMD/CN1) 0.264x (73.6% faster)
Base64 SIMD decode 63.000 ms
Base64 decode ratio (SIMD/CN1) 0.496x (50.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 12.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.750x (25.0% faster)
Image applyMask (SIMD off) 25.000 ms
Image applyMask (SIMD on) 19.000 ms
Image applyMask ratio (SIMD on/off) 0.760x (24.0% faster)
Image modifyAlpha (SIMD off) 17.000 ms
Image modifyAlpha (SIMD on) 12.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.706x (29.4% faster)
Image modifyAlpha removeColor (SIMD off) 21.000 ms
Image modifyAlpha removeColor (SIMD on) 12.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.571x (42.9% faster)

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 181 screenshots: 181 matched.
✅ JavaScript-port screenshot tests passed.

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 148 screenshots: 148 matched.
✅ Native Mac screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 342 seconds

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 107ms / native 7ms = 15.2x speedup
SIMD float-mul (64K x300) java 123ms / native 53ms = 2.3x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 231.000 ms
Base64 CN1 decode 146.000 ms
Base64 native encode 897.000 ms
Base64 encode ratio (CN1/native) 0.258x (74.2% faster)
Base64 native decode 383.000 ms
Base64 decode ratio (CN1/native) 0.381x (61.9% faster)
Base64 SIMD encode 76.000 ms
Base64 encode ratio (SIMD/CN1) 0.329x (67.1% faster)
Base64 SIMD decode 51.000 ms
Base64 decode ratio (SIMD/CN1) 0.349x (65.1% faster)
Base64 encode ratio (SIMD/native) 0.085x (91.5% faster)
Base64 decode ratio (SIMD/native) 0.133x (86.7% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 10.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.200x (80.0% faster)
Image applyMask (SIMD off) 73.000 ms
Image applyMask (SIMD on) 62.000 ms
Image applyMask ratio (SIMD on/off) 0.849x (15.1% faster)
Image modifyAlpha (SIMD off) 88.000 ms
Image modifyAlpha (SIMD on) 99.000 ms
Image modifyAlpha ratio (SIMD on/off) 1.125x (12.5% slower)
Image modifyAlpha removeColor (SIMD off) 135.000 ms
Image modifyAlpha removeColor (SIMD on) 84.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.622x (37.8% faster)

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 144 screenshots: 144 matched.
✅ Native Apple TV (tvOS, Metal) screenshot tests passed.

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 149 screenshots: 149 matched.
✅ Native iOS Metal screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 505 seconds

Build and Run Timing

Metric Duration
Simulator Boot 103000 ms
Simulator Boot (Run) 1000 ms
App Install 15000 ms
App Launch 93000 ms
Test Execution 518000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 104ms / native 7ms = 14.8x speedup
SIMD float-mul (64K x300) java 76ms / native 4ms = 19.0x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 463.000 ms
Base64 CN1 decode 237.000 ms
Base64 native encode 1594.000 ms
Base64 encode ratio (CN1/native) 0.290x (71.0% faster)
Base64 native decode 530.000 ms
Base64 decode ratio (CN1/native) 0.447x (55.3% faster)
Base64 SIMD encode 92.000 ms
Base64 encode ratio (SIMD/CN1) 0.199x (80.1% faster)
Base64 SIMD decode 64.000 ms
Base64 decode ratio (SIMD/CN1) 0.270x (73.0% faster)
Base64 encode ratio (SIMD/native) 0.058x (94.2% faster)
Base64 decode ratio (SIMD/native) 0.121x (87.9% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 13.000 ms
Image createMask (SIMD on) 40.000 ms
Image createMask ratio (SIMD on/off) 3.077x (207.7% slower)
Image applyMask (SIMD off) 353.000 ms
Image applyMask (SIMD on) 70.000 ms
Image applyMask ratio (SIMD on/off) 0.198x (80.2% faster)
Image modifyAlpha (SIMD off) 67.000 ms
Image modifyAlpha (SIMD on) 81.000 ms
Image modifyAlpha ratio (SIMD on/off) 1.209x (20.9% slower)
Image modifyAlpha removeColor (SIMD off) 182.000 ms
Image modifyAlpha removeColor (SIMD on) 220.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.209x (20.9% slower)

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 217 screenshots: 217 matched.
✅ Native Apple Watch (watchOS, Core Graphics) screenshot tests passed.

@shai-almog

shai-almog commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 143 screenshots: 143 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 448 seconds

Build and Run Timing

Metric Duration
Simulator Boot 85000 ms
Simulator Boot (Run) 1000 ms
App Install 19000 ms
App Launch 5000 ms
Test Execution 578000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 83ms / native 6ms = 13.8x speedup
SIMD float-mul (64K x300) java 89ms / native 4ms = 22.2x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 454.000 ms
Base64 CN1 decode 213.000 ms
Base64 native encode 792.000 ms
Base64 encode ratio (CN1/native) 0.573x (42.7% faster)
Base64 native decode 476.000 ms
Base64 decode ratio (CN1/native) 0.447x (55.3% faster)
Base64 SIMD encode 194.000 ms
Base64 encode ratio (SIMD/CN1) 0.427x (57.3% faster)
Base64 SIMD decode 133.000 ms
Base64 decode ratio (SIMD/CN1) 0.624x (37.6% faster)
Base64 encode ratio (SIMD/native) 0.245x (75.5% faster)
Base64 decode ratio (SIMD/native) 0.279x (72.1% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 9.000 ms
Image createMask (SIMD on) 3.000 ms
Image createMask ratio (SIMD on/off) 0.333x (66.7% faster)
Image applyMask (SIMD off) 64.000 ms
Image applyMask (SIMD on) 49.000 ms
Image applyMask ratio (SIMD on/off) 0.766x (23.4% faster)
Image modifyAlpha (SIMD off) 88.000 ms
Image modifyAlpha (SIMD on) 51.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.580x (42.0% faster)
Image modifyAlpha removeColor (SIMD off) 65.000 ms
Image modifyAlpha removeColor (SIMD on) 96.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.477x (47.7% slower)

@shai-almog
shai-almog merged commit b45ee65 into master Aug 4, 2026
58 of 59 checks passed
@shai-almog
shai-almog deleted the fix/js-native-interface-issupported branch August 4, 2026 08:01
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.

[Bug] javascript version, trapping absence of native methods

2 participants