Skip to content

Offload vector map tile work from EDT - #5350

Merged
shai-almog merged 2 commits into
masterfrom
offload-vector-map-tile-work
Jul 9, 2026
Merged

Offload vector map tile work from EDT#5350
shai-almog merged 2 commits into
masterfrom
offload-vector-map-tile-work

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Summary

This moves vector map tile IO and heavy tile preparation off the event dispatch thread.

  • Add a shared serial map tile worker for tile IO, gzip/TileJSON parsing, MVT decode, label extraction, vector rasterization, and raster image decoding.
  • Keep front-end cache mutation and repaint callbacks on the EDT.
  • Add generation tracking so stale async tile results cannot repopulate caches after source, style, pixel-ratio, or cache resets.
  • Route bundled/demo tile loading through the same worker path.

Impact

Map paints now request tile jobs from the EDT and receive only lightweight completion callbacks there, reducing UI stalls and GC pressure from tile read/decode/parse/allocation work.

Root Cause

Tile callbacks were delivered on the EDT and VectorMapEngine decoded MVT bytes, extracted labels, rasterized vector tiles, and decoded raster images inline. Bundled tiles also read resources from a CN.callSerially() block.

Validation

  • git diff --check
  • JAVA_HOME=/Users/shai/Library/Java/JavaVirtualMachines/azul-1.8.0_372/Contents/Home PATH=/Users/shai/Library/Java/JavaVirtualMachines/azul-1.8.0_372/Contents/Home/bin:$PATH mvn -pl core-unittests -am -DunitTests=true -Dmaven.javadoc.skip=true -Plocal-dev-javase -Dtest=MapsVectorTest,MapsVectorInternalsTest -Dsurefire.failIfNoSpecifiedTests=false test

Result: 21 tests passed.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Cloudflare Preview

@github-actions

github-actions Bot commented Jul 9, 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.

@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 144 screenshots: 144 matched.

Native Android coverage

  • 📊 Line coverage: 10.05% (10236/101807 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.90% (50348/565700), branch 4.41% (2270/51498), complexity 4.45% (2424/54471), method 6.75% (1907/28261), class 10.85% (436/4020)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 10.05% (10236/101807 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.90% (50348/565700), branch 4.41% (2270/51498), complexity 4.45% (2424/54471), method 6.75% (1907/28261), class 10.85% (436/4020)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend scalar fallback (no native SIMD)
SIMD int-add (64K x300) java 173ms / native 65ms = 2.6x speedup
SIMD float-mul (64K x300) java 99ms / native 45ms = 2.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 177.000 ms
Base64 CN1 decode 270.000 ms
Base64 native encode 585.000 ms
Base64 encode ratio (CN1/native) 0.303x (69.7% faster)
Base64 native decode 984.000 ms
Base64 decode ratio (CN1/native) 0.274x (72.6% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 80ms / native 4ms = 20.0x speedup
SIMD float-mul (64K x300) java 80ms / native 4ms = 20.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 448.000 ms
Base64 CN1 decode 278.000 ms
Base64 native encode 1369.000 ms
Base64 encode ratio (CN1/native) 0.327x (67.3% faster)
Base64 native decode 824.000 ms
Base64 decode ratio (CN1/native) 0.337x (66.3% faster)
Base64 SIMD encode 64.000 ms
Base64 encode ratio (SIMD/CN1) 0.143x (85.7% faster)
Base64 SIMD decode 81.000 ms
Base64 decode ratio (SIMD/CN1) 0.291x (70.9% faster)
Base64 encode ratio (SIMD/native) 0.047x (95.3% faster)
Base64 decode ratio (SIMD/native) 0.098x (90.2% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 23.000 ms
Image createMask (SIMD on) 27.000 ms
Image createMask ratio (SIMD on/off) 1.174x (17.4% slower)
Image applyMask (SIMD off) 154.000 ms
Image applyMask (SIMD on) 256.000 ms
Image applyMask ratio (SIMD on/off) 1.662x (66.2% slower)
Image modifyAlpha (SIMD off) 164.000 ms
Image modifyAlpha (SIMD on) 126.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.768x (23.2% faster)
Image modifyAlpha removeColor (SIMD off) 171.000 ms
Image modifyAlpha removeColor (SIMD on) 221.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.292x (29.2% slower)

@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 52000 ms
Simulator Boot (Run) 1000 ms
App Install 10000 ms
App Launch 2000 ms
Test Execution 350000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 63ms / native 5ms = 12.6x speedup
SIMD float-mul (64K x300) java 66ms / native 4ms = 16.5x 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 378.000 ms
Base64 CN1 decode 259.000 ms
Base64 native encode 513.000 ms
Base64 encode ratio (CN1/native) 0.737x (26.3% faster)
Base64 native decode 575.000 ms
Base64 decode ratio (CN1/native) 0.450x (55.0% faster)
Base64 SIMD encode 74.000 ms
Base64 encode ratio (SIMD/CN1) 0.196x (80.4% faster)
Base64 SIMD decode 89.000 ms
Base64 decode ratio (SIMD/CN1) 0.344x (65.6% faster)
Base64 encode ratio (SIMD/native) 0.144x (85.6% faster)
Base64 decode ratio (SIMD/native) 0.155x (84.5% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 26.000 ms
Image createMask (SIMD on) 1.000 ms
Image createMask ratio (SIMD on/off) 0.038x (96.2% faster)
Image applyMask (SIMD off) 74.000 ms
Image applyMask (SIMD on) 38.000 ms
Image applyMask ratio (SIMD on/off) 0.514x (48.6% faster)
Image modifyAlpha (SIMD off) 72.000 ms
Image modifyAlpha (SIMD on) 46.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.639x (36.1% faster)
Image modifyAlpha removeColor (SIMD off) 76.000 ms
Image modifyAlpha removeColor (SIMD on) 59.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.776x (22.4% faster)

@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

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

@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

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

@shai-almog
shai-almog force-pushed the offload-vector-map-tile-work branch from e33a77b to d626b5d Compare July 9, 2026 03:03
@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 94000 ms
Simulator Boot (Run) 1000 ms
App Install 12000 ms
App Launch 5000 ms
Test Execution 437000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 135ms / native 3ms = 45.0x speedup
SIMD float-mul (64K x300) java 98ms / native 8ms = 12.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 401.000 ms
Base64 CN1 decode 866.000 ms
Base64 native encode 580.000 ms
Base64 encode ratio (CN1/native) 0.691x (30.9% faster)
Base64 native decode 684.000 ms
Base64 decode ratio (CN1/native) 1.266x (26.6% slower)
Base64 SIMD encode 272.000 ms
Base64 encode ratio (SIMD/CN1) 0.678x (32.2% faster)
Base64 SIMD decode 174.000 ms
Base64 decode ratio (SIMD/CN1) 0.201x (79.9% faster)
Base64 encode ratio (SIMD/native) 0.469x (53.1% faster)
Base64 decode ratio (SIMD/native) 0.254x (74.6% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 29.000 ms
Image createMask (SIMD on) 6.000 ms
Image createMask ratio (SIMD on/off) 0.207x (79.3% faster)
Image applyMask (SIMD off) 109.000 ms
Image applyMask (SIMD on) 70.000 ms
Image applyMask ratio (SIMD on/off) 0.642x (35.8% faster)
Image modifyAlpha (SIMD off) 102.000 ms
Image modifyAlpha (SIMD on) 85.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.833x (16.7% faster)
Image modifyAlpha removeColor (SIMD off) 196.000 ms
Image modifyAlpha removeColor (SIMD on) 83.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.423x (57.7% faster)

@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 140 screenshots: 140 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 70ms / native 4ms = 17.5x speedup
SIMD float-mul (64K x300) java 72ms / native 4ms = 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 280.000 ms
Base64 CN1 decode 175.000 ms
Base64 SIMD encode 151.000 ms
Base64 encode ratio (SIMD/CN1) 0.539x (46.1% faster)
Base64 SIMD decode 133.000 ms
Base64 decode ratio (SIMD/CN1) 0.760x (24.0% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 48.000 ms
Image createMask (SIMD on) 26.000 ms
Image createMask ratio (SIMD on/off) 0.542x (45.8% faster)
Image applyMask (SIMD off) 86.000 ms
Image applyMask (SIMD on) 62.000 ms
Image applyMask ratio (SIMD on/off) 0.721x (27.9% faster)
Image modifyAlpha (SIMD off) 92.000 ms
Image modifyAlpha (SIMD on) 63.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.685x (31.5% faster)
Image modifyAlpha removeColor (SIMD off) 88.000 ms
Image modifyAlpha removeColor (SIMD on) 33.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.375x (62.5% faster)

@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

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

@shai-almog

shai-almog commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 141 screenshots: 141 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 Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 141 screenshots: 141 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 force-pushed the offload-vector-map-tile-work branch from d626b5d to 34f1226 Compare July 9, 2026 06:14
@shai-almog
shai-almog merged commit e358174 into master Jul 9, 2026
39 checks passed
@shai-almog
shai-almog deleted the offload-vector-map-tile-work branch July 9, 2026 14:24
shai-almog added a commit that referenced this pull request Jul 9, 2026
…paint (#5352)

Conflict resolution:
- VectorMapEngine: took master wholesale. #5350's hasRenderedVisibleTiles()/MapView.isMapReady()
  supersedes this branch's isViewportFullyRendered() -- same visible-tile-coverage idea, but the
  master probe also actively computes and REQUESTS the visible tile set, so it is deterministic
  even before the first paint. The branch-side duplicate is dropped.
- VectorMapScreenshotBaseTest: master's isMapReady() probe (incl. the NativeMap branch), keeping
  this branch's two hardening pieces on top: the 30s wait cap (starved CI simulators exceeded
  the old 9s on heavy first renders) and the CN1SS:WARN when capturing at the cap so a slow leg
  attributes itself instead of surfacing as a mystery mismatch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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