Skip to content

Remove redundant paint-scope state warnings, keep clip over-pop hard fail (#5058)#5147

Merged
shai-almog merged 1 commit into
masterfrom
revert-paint-scope-warnings
Jun 2, 2026
Merged

Remove redundant paint-scope state warnings, keep clip over-pop hard fail (#5058)#5147
shai-almog merged 1 commit into
masterfrom
revert-paint-scope-warnings

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

The simulator's per-paint-scope state diagnostic added in #5058 (deduped in #5102) wrapped every Component.paint / paintBackground / Painter.paint / glass-pane dispatch, compared clip/transform/color/font/composite before and after, logged a paint-scope: ... did not restore Graphics state warning, and auto-restored any drift.

In practice the warnings were redundant noise:

  • Components legitimately set their foreground color and font from their Style without restoring them — that's the long-standing Codename One paint contract, and it's harmless because the next component sets its own before drawing. So the color not restored / font not restored reports were false positives against core classes (Label, Button, TextField, BGPainter, Container, Toolbar, …) that can't reasonably be "fixed", and they flooded the EDT log.
  • The auto-restore also made the simulator mutate live Graphics state mid-render, diverging from on-device behavior.

The genuinely valuable part is kept: JavaSEPort.popClip still throws IllegalStateException when there is no matching pushClip. That's a hard fail that catches real clip-stack corruption at its source before it can manifest as drift/crashes on device.

Changes

  • JavaSEPort.java — removed the PaintScopeSnapshot class, the paintScopes / paintScopeChecksEnabled / reportedPaintScopeLeaks fields, the begin/endPaintScope overrides (snapshot + diff + auto-restore + logging), and the helpers (clipStackDepth, trimClipStack, appendDiff, ownerClass, equalsNullSafe, sameShape, describe). Reverted disposeGraphics. Kept the popClip() over-pop hard-fail guard.
  • Component.java (5 sites) / Form.java (glass pane) — reverted the begin/endPaintScope try/finally wrapping back to direct paint calls.
  • CodenameOneImplementation.java — removed the no-op begin/endPaintScope hook methods.
  • PaintScopeTest.java — trimmed to the two over-pop guard tests; dropped the leak/auto-restore/dedup tests that depended on the removed API.

Net: ~475 lines removed across 5 files; zero remaining references to the paint-scope diagnostic.

🤖 Generated with Claude Code

…fail (#5058)

The simulator's per-paint-scope state diagnostic (#5058, #5102) compared
clip/transform/color/font/composite before and after every
Component.paint / paintBackground / Painter.paint / glass-pane dispatch,
logged a "did not restore Graphics state" warning, and auto-restored the
drift. In practice these warnings were noise: components legitimately set
their foreground color and font from their Style without restoring (the
long-standing CN1 paint contract, harmless because the next draw sets its
own), so the color/font reports were false positives against core classes
that cannot reasonably be "fixed". The auto-restore also made the simulator
mutate live Graphics state mid-render, diverging from device behavior.

The genuinely valuable part -- the clip stack hard fail -- is retained:
JavaSEPort.popClip still throws IllegalStateException when there is no
matching pushClip, catching real clip-stack corruption at its source before
it can crash on device.

This removes the begin/endPaintScope snapshot/diff/log/auto-restore
machinery and its no-op hooks, reverting the paint dispatch sites in
Component/Form to direct calls, and trims PaintScopeTest to the two
over-pop guard tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented Jun 2, 2026

Compared 11 screenshots: 11 matched.
✅ JavaSE simulator integration screenshots matched stored baselines.

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented Jun 2, 2026

Compared 122 screenshots: 122 matched.

Native Android coverage

  • 📊 Line coverage: 13.02% (7682/59012 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.55% (38180/361979), branch 4.53% (1543/34080), complexity 5.52% (1809/32758), method 9.64% (1481/15358), class 15.77% (339/2150)
    • 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)
      • 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)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 13.02% (7682/59012 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.55% (38180/361979), branch 4.53% (1543/34080), complexity 5.52% (1809/32758), method 9.64% (1481/15358), class 15.77% (339/2150)
    • 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)
      • 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)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 988.000 ms
Base64 CN1 encode 441.000 ms
Base64 encode ratio (CN1/native) 0.446x (55.4% faster)
Base64 native decode 1020.000 ms
Base64 CN1 decode 235.000 ms
Base64 decode ratio (CN1/native) 0.230x (77.0% faster)
Image encode benchmark status skipped (SIMD unsupported)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

✅ 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
Copy link
Copy Markdown
Collaborator Author

shai-almog commented Jun 2, 2026

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

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 949.000 ms
Base64 CN1 encode 1457.000 ms
Base64 encode ratio (CN1/native) 1.535x (53.5% slower)
Base64 native decode 446.000 ms
Base64 CN1 decode 1069.000 ms
Base64 decode ratio (CN1/native) 2.397x (139.7% slower)
Base64 SIMD encode 484.000 ms
Base64 encode ratio (SIMD/native) 0.510x (49.0% faster)
Base64 encode ratio (SIMD/CN1) 0.332x (66.8% faster)
Base64 SIMD decode 444.000 ms
Base64 decode ratio (SIMD/native) 0.996x (0.4% faster)
Base64 decode ratio (SIMD/CN1) 0.415x (58.5% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 80.000 ms
Image createMask (SIMD on) 16.000 ms
Image createMask ratio (SIMD on/off) 0.200x (80.0% faster)
Image applyMask (SIMD off) 227.000 ms
Image applyMask (SIMD on) 176.000 ms
Image applyMask ratio (SIMD on/off) 0.775x (22.5% faster)
Image modifyAlpha (SIMD off) 171.000 ms
Image modifyAlpha (SIMD on) 106.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.620x (38.0% faster)
Image modifyAlpha removeColor (SIMD off) 216.000 ms
Image modifyAlpha removeColor (SIMD on) 117.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.542x (45.8% faster)
Image PNG encode (SIMD off) 1173.000 ms
Image PNG encode (SIMD on) 880.000 ms
Image PNG encode ratio (SIMD on/off) 0.750x (25.0% faster)
Image JPEG encode 533.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented Jun 2, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 59000 ms
Simulator Boot (Run) 1000 ms
App Install 26000 ms
App Launch 4000 ms
Test Execution 301000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 547.000 ms
Base64 CN1 encode 1195.000 ms
Base64 encode ratio (CN1/native) 2.185x (118.5% slower)
Base64 native decode 272.000 ms
Base64 CN1 decode 916.000 ms
Base64 decode ratio (CN1/native) 3.368x (236.8% slower)
Base64 SIMD encode 396.000 ms
Base64 encode ratio (SIMD/native) 0.724x (27.6% faster)
Base64 encode ratio (SIMD/CN1) 0.331x (66.9% faster)
Base64 SIMD decode 380.000 ms
Base64 decode ratio (SIMD/native) 1.397x (39.7% slower)
Base64 decode ratio (SIMD/CN1) 0.415x (58.5% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 58.000 ms
Image createMask (SIMD on) 10.000 ms
Image createMask ratio (SIMD on/off) 0.172x (82.8% faster)
Image applyMask (SIMD off) 118.000 ms
Image applyMask (SIMD on) 49.000 ms
Image applyMask ratio (SIMD on/off) 0.415x (58.5% faster)
Image modifyAlpha (SIMD off) 113.000 ms
Image modifyAlpha (SIMD on) 51.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.451x (54.9% faster)
Image modifyAlpha removeColor (SIMD off) 135.000 ms
Image modifyAlpha removeColor (SIMD on) 63.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.467x (53.3% faster)
Image PNG encode (SIMD off) 960.000 ms
Image PNG encode (SIMD on) 845.000 ms
Image PNG encode ratio (SIMD on/off) 0.880x (12.0% faster)
Image JPEG encode 411.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented Jun 2, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 102000 ms
Simulator Boot (Run) 1000 ms
App Install 17000 ms
App Launch 10000 ms
Test Execution 300000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1028.000 ms
Base64 CN1 encode 2293.000 ms
Base64 encode ratio (CN1/native) 2.231x (123.1% slower)
Base64 native decode 569.000 ms
Base64 CN1 decode 1385.000 ms
Base64 decode ratio (CN1/native) 2.434x (143.4% slower)
Base64 SIMD encode 588.000 ms
Base64 encode ratio (SIMD/native) 0.572x (42.8% faster)
Base64 encode ratio (SIMD/CN1) 0.256x (74.4% faster)
Base64 SIMD decode 626.000 ms
Base64 decode ratio (SIMD/native) 1.100x (10.0% slower)
Base64 decode ratio (SIMD/CN1) 0.452x (54.8% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 129.000 ms
Image createMask (SIMD on) 29.000 ms
Image createMask ratio (SIMD on/off) 0.225x (77.5% faster)
Image applyMask (SIMD off) 605.000 ms
Image applyMask (SIMD on) 265.000 ms
Image applyMask ratio (SIMD on/off) 0.438x (56.2% faster)
Image modifyAlpha (SIMD off) 539.000 ms
Image modifyAlpha (SIMD on) 263.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.488x (51.2% faster)
Image modifyAlpha removeColor (SIMD off) 468.000 ms
Image modifyAlpha removeColor (SIMD on) 171.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.365x (63.5% faster)
Image PNG encode (SIMD off) 1810.000 ms
Image PNG encode (SIMD on) 1216.000 ms
Image PNG encode ratio (SIMD on/off) 0.672x (32.8% faster)
Image JPEG encode 656.000 ms

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Cloudflare Preview

@shai-almog shai-almog merged commit d8feb8d into master Jun 2, 2026
30 of 35 checks passed
@shai-almog shai-almog deleted the revert-paint-scope-warnings branch June 2, 2026 04:55
@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented Jun 2, 2026

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

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