Skip to content

Fix DesktopMode iOS screenshot late-present race (700ms -> 1500ms settle)#5316

Open
shai-almog wants to merge 1 commit into
masterfrom
fix/desktopmode-late-present-settle
Open

Fix DesktopMode iOS screenshot late-present race (700ms -> 1500ms settle)#5316
shai-almog wants to merge 1 commit into
masterfrom
fix/desktopmode-late-present-settle

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Problem

The DesktopMode iOS screenshot test intermittently captures the wrong form — observed in CI capturing the preceding MutableImageClip form under the DesktopMode name. This is the documented iOS Metal late-present race: the heavy 30-row scrollable form's first frame is presented just after Display.screenshot() reads the framebuffer, so the grab returns the previous test's pixels.

It surfaced repeatedly on the device-input PR (#5309) CI as a build-ios / packaging failure that "cleared on re-run" — i.e. a real timing bug, not noise.

Root cause

DesktopModeScreenshotTest already opts into the sanctioned extraSettleBeforeCaptureMillis() mitigation (repaint + wait for GPU present before capture), but its 700ms value still loses the race on a starved CI runner.

Fix

Raise the settle to 1500ms — the same post-present margin OrientationLockScreenshotTest already relies on. The captured form is unchanged, so the reference image is unaffected; only the wait before the grab is longer.

🤖 Generated with Claude Code

…tle)

The DesktopMode capture intermittently shipped the preceding test's framebuffer
(observed: it captured the MutableImageClip form) -- the documented iOS Metal
late-present race where the heavy 30-row form's first frame is presented just
after Display.screenshot() reads the framebuffer. The test already opts into the
extraSettleBeforeCaptureMillis repaint-and-wait mitigation, but 700ms still lost
the race on a starved CI runner. Raise it to the same 1500ms post-present margin
the OrientationLock test already relies on. The captured form is unchanged, so
the reference image is unaffected -- only the settle before the grab is longer.
@shai-almog

shai-almog commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 139 screenshots: 139 matched.

Native Android coverage

  • 📊 Line coverage: 9.14% (9115/99743 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.05% (44780/556236), branch 3.71% (1878/50588), complexity 4.00% (2151/53777), method 6.23% (1746/28022), class 10.16% (404/3978)
    • 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: 9.14% (9115/99743 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.05% (44780/556236), branch 3.71% (1878/50588), complexity 4.00% (2151/53777), method 6.23% (1746/28022), class 10.16% (404/3978)
    • 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 192ms / native 135ms = 1.4x speedup
SIMD float-mul (64K x300) java 125ms / native 48ms = 2.6x 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 210.000 ms
Base64 CN1 decode 159.000 ms
Base64 native encode 1410.000 ms
Base64 encode ratio (CN1/native) 0.149x (85.1% faster)
Base64 native decode 929.000 ms
Base64 decode ratio (CN1/native) 0.171x (82.9% faster)
Image encode benchmark status skipped (SIMD unsupported)
@shai-almog

shai-almog commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

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

@shai-almog

shai-almog commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 135 screenshots: 135 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 63ms / native 3ms = 21.0x speedup
SIMD float-mul (64K x300) java 61ms / native 3ms = 20.3x speedup
SIMD kernel correctness PASS (native result == scalar reference)
@shai-almog

shai-almog commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 137 screenshots: 137 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 Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 137 screenshots: 137 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 Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 53000 ms
Simulator Boot (Run) 1000 ms
App Install 11000 ms
App Launch 1000 ms
Test Execution 301000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 52ms / native 3ms = 17.3x speedup
SIMD float-mul (64K x300) java 72ms / native 2ms = 36.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 427.000 ms
Base64 CN1 decode 208.000 ms
Base64 native encode 423.000 ms
Base64 encode ratio (CN1/native) 1.009x (0.9% slower)
Base64 native decode 262.000 ms
Base64 decode ratio (CN1/native) 0.794x (20.6% faster)
Base64 SIMD encode 52.000 ms
Base64 encode ratio (SIMD/CN1) 0.122x (87.8% faster)
Base64 SIMD decode 45.000 ms
Base64 decode ratio (SIMD/CN1) 0.216x (78.4% faster)
Base64 encode ratio (SIMD/native) 0.123x (87.7% faster)
Base64 decode ratio (SIMD/native) 0.172x (82.8% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 16.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.125x (87.5% faster)
Image applyMask (SIMD off) 42.000 ms
Image applyMask (SIMD on) 27.000 ms
Image applyMask ratio (SIMD on/off) 0.643x (35.7% faster)
Image modifyAlpha (SIMD off) 60.000 ms
Image modifyAlpha (SIMD on) 25.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.417x (58.3% faster)
Image modifyAlpha removeColor (SIMD off) 62.000 ms
Image modifyAlpha removeColor (SIMD on) 24.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.387x (61.3% faster)
@shai-almog

shai-almog commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

iOS screenshot updates

Compared 134 screenshots: 132 matched, 2 updated.

  • DesktopMode — updated screenshot. Screenshot differs (1179x2556 px, bit depth 8).

    DesktopMode
    Preview info: JPEG preview quality 70; JPEG preview quality 70; downscaled to 825x1789.
    Full-resolution PNG saved as DesktopMode.png in workflow artifacts.

  • landscape — updated screenshot. Screenshot differs (1179x2556 px, bit depth 8).

    landscape
    Preview info: JPEG preview quality 70; JPEG preview quality 70; downscaled to 825x1789.
    Full-resolution PNG saved as landscape.png in workflow artifacts.

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 97000 ms
Simulator Boot (Run) 0 ms
App Install 14000 ms
App Launch 3000 ms
Test Execution 471000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 120ms / native 4ms = 30.0x speedup
SIMD float-mul (64K x300) java 78ms / native 3ms = 26.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 489.000 ms
Base64 CN1 decode 411.000 ms
Base64 native encode 1206.000 ms
Base64 encode ratio (CN1/native) 0.405x (59.5% faster)
Base64 native decode 408.000 ms
Base64 decode ratio (CN1/native) 1.007x (0.7% slower)
Base64 SIMD encode 137.000 ms
Base64 encode ratio (SIMD/CN1) 0.280x (72.0% faster)
Base64 SIMD decode 110.000 ms
Base64 decode ratio (SIMD/CN1) 0.268x (73.2% faster)
Base64 encode ratio (SIMD/native) 0.114x (88.6% faster)
Base64 decode ratio (SIMD/native) 0.270x (73.0% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 42.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.214x (78.6% faster)
Image applyMask (SIMD off) 607.000 ms
Image applyMask (SIMD on) 578.000 ms
Image applyMask ratio (SIMD on/off) 0.952x (4.8% faster)
Image modifyAlpha (SIMD off) 280.000 ms
Image modifyAlpha (SIMD on) 244.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.871x (12.9% faster)
Image modifyAlpha removeColor (SIMD off) 321.000 ms
Image modifyAlpha removeColor (SIMD on) 294.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.916x (8.4% faster)
@shai-almog

shai-almog commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 137 screenshots: 137 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 86ms / native 4ms = 21.5x speedup
SIMD float-mul (64K x300) java 83ms / native 4ms = 20.7x 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 478.000 ms
Base64 CN1 decode 419.000 ms
Base64 native encode 818.000 ms
Base64 encode ratio (CN1/native) 0.584x (41.6% faster)
Base64 native decode 717.000 ms
Base64 decode ratio (CN1/native) 0.584x (41.6% faster)
Base64 SIMD encode 113.000 ms
Base64 encode ratio (SIMD/CN1) 0.236x (76.4% faster)
Base64 SIMD decode 96.000 ms
Base64 decode ratio (SIMD/CN1) 0.229x (77.1% faster)
Base64 encode ratio (SIMD/native) 0.138x (86.2% faster)
Base64 decode ratio (SIMD/native) 0.134x (86.6% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 35.000 ms
Image createMask (SIMD on) 5.000 ms
Image createMask ratio (SIMD on/off) 0.143x (85.7% faster)
Image applyMask (SIMD off) 287.000 ms
Image applyMask (SIMD on) 227.000 ms
Image applyMask ratio (SIMD on/off) 0.791x (20.9% faster)
Image modifyAlpha (SIMD off) 198.000 ms
Image modifyAlpha (SIMD on) 120.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.606x (39.4% faster)
Image modifyAlpha removeColor (SIMD off) 139.000 ms
Image modifyAlpha removeColor (SIMD on) 82.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.590x (41.0% faster)
@shai-almog

shai-almog commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

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

@shai-almog

shai-almog commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant