Skip to content

simulator: guard window-bounds prefs against corruption from Larger Text scaling#4935

Merged
shai-almog merged 1 commit into
masterfrom
fix/window-bounds-prefs-safeguards
May 13, 2026
Merged

simulator: guard window-bounds prefs against corruption from Larger Text scaling#4935
shai-almog merged 1 commit into
masterfrom
fix/window-bounds-prefs-safeguards

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Picking Simulate -> Larger Text -> Extra Extra Extra Large (and the larger Accessibility steps) could collapse the simulator frame; refreshSkin()'s pack() produced an unusably small geometry that the existing componentResized listener wrote straight into prefs. Every subsequent launch restored the bad bounds, leaving the window stuck.
  • Add JavaSEPort.isUsableWindowBounds(Rectangle), used on both write and read paths, that rejects null/degenerate/oversize rectangles and frames without a meaningful on-screen overlap.
  • Extract parsePersistedBounds(String) so a malformed window.bounds pref no longer aborts init() with a NumberFormatException. Corrupt entries are removed on read so a single bad event cannot survive across launches.
  • Apply the same guards to AppPanel's per-panel preferredWindowBounds.{x,y,width,height} keys.

Test plan

  • mvn -pl javase clean compile -Plocal-dev-javase -> BUILD SUCCESS
  • mvn -pl javase test -Dtest=JavaSEPortWindowBoundsTest -> 15/15 pass (collapsed frame, just-below-floor, absurd size, sliver-on-screen, far-off-screen, malformed prefs, whitespace, negative origin, write/parse roundtrip)
  • Manual: pick every Larger Text option (including Accessibility 5), close the simulator, reopen, confirm the frame returns to a usable size
  • Manual: hand-edit the window.bounds pref to 0,0,5,5 (or to a malformed value) and confirm the next launch falls back cleanly and clears the entry

🤖 Generated with Claude Code

…ext scaling

Picking Simulate -> Larger Text -> Extra Extra Extra Large (and the larger
Accessibility steps) could collapse the simulator frame; refreshSkin()'s
pack() produced an unusably small geometry that the existing
componentResized listener wrote straight into prefs. The next launch
restored the bad bounds, leaving the window stuck.

Add a shared validator (JavaSEPort.isUsableWindowBounds) used on both
write and read sides to reject degenerate, oversize, or off-screen
rectangles, and extract parsePersistedBounds so a malformed pref no
longer aborts init() with a NumberFormatException. On read, corrupt
entries are removed so a single bad event does not survive across
launches. AppPanel applies the same guards to its per-panel
preferredWindowBounds keys.

Adds JavaSEPortWindowBoundsTest covering null/tiny/huge/off-screen
inputs, parse rejection of malformed strings, and a write/parse
roundtrip.

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

shai-almog commented May 13, 2026

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

@github-actions
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
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 13, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 62000 ms
Simulator Boot (Run) 1000 ms
App Install 12000 ms
App Launch 8000 ms
Test Execution 276000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1241.000 ms
Base64 CN1 encode 1194.000 ms
Base64 encode ratio (CN1/native) 0.962x (3.8% faster)
Base64 native decode 825.000 ms
Base64 CN1 decode 923.000 ms
Base64 decode ratio (CN1/native) 1.119x (11.9% slower)
Base64 SIMD encode 387.000 ms
Base64 encode ratio (SIMD/native) 0.312x (68.8% faster)
Base64 encode ratio (SIMD/CN1) 0.324x (67.6% faster)
Base64 SIMD decode 365.000 ms
Base64 decode ratio (SIMD/native) 0.442x (55.8% faster)
Base64 decode ratio (SIMD/CN1) 0.395x (60.5% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 58.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.155x (84.5% faster)
Image applyMask (SIMD off) 127.000 ms
Image applyMask (SIMD on) 58.000 ms
Image applyMask ratio (SIMD on/off) 0.457x (54.3% faster)
Image modifyAlpha (SIMD off) 116.000 ms
Image modifyAlpha (SIMD on) 56.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.483x (51.7% faster)
Image modifyAlpha removeColor (SIMD off) 141.000 ms
Image modifyAlpha removeColor (SIMD on) 68.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.482x (51.8% faster)
Image PNG encode (SIMD off) 929.000 ms
Image PNG encode (SIMD on) 806.000 ms
Image PNG encode ratio (SIMD on/off) 0.868x (13.2% faster)
Image JPEG encode 437.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 13, 2026

Compared 106 screenshots: 106 matched.

Native Android coverage

  • 📊 Line coverage: 11.39% (6298/55313 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 9.05% (31186/344567), branch 3.93% (1288/32768), complexity 5.02% (1578/31420), method 8.77% (1289/14701), class 14.81% (295/1992)
    • 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: 11.39% (6298/55313 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 9.05% (31186/344567), branch 3.93% (1288/32768), complexity 5.02% (1578/31420), method 8.77% (1289/14701), class 14.81% (295/1992)
    • 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 892.000 ms
Base64 CN1 encode 137.000 ms
Base64 encode ratio (CN1/native) 0.154x (84.6% faster)
Base64 native decode 662.000 ms
Base64 CN1 decode 240.000 ms
Base64 decode ratio (CN1/native) 0.363x (63.7% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 13, 2026

iOS Metal screenshot updates

Compared 104 screenshots: 103 matched, 1 updated.

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

    BrowserComponent
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as BrowserComponent.png in workflow artifacts.

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 130000 ms
Simulator Boot (Run) 3000 ms
App Install 15000 ms
App Launch 8000 ms
Test Execution 277000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 2067.000 ms
Base64 CN1 encode 2159.000 ms
Base64 encode ratio (CN1/native) 1.045x (4.5% slower)
Base64 native decode 1188.000 ms
Base64 CN1 decode 1248.000 ms
Base64 decode ratio (CN1/native) 1.051x (5.1% slower)
Base64 SIMD encode 596.000 ms
Base64 encode ratio (SIMD/native) 0.288x (71.2% faster)
Base64 encode ratio (SIMD/CN1) 0.276x (72.4% faster)
Base64 SIMD decode 744.000 ms
Base64 decode ratio (SIMD/native) 0.626x (37.4% faster)
Base64 decode ratio (SIMD/CN1) 0.596x (40.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 128.000 ms
Image createMask (SIMD on) 10.000 ms
Image createMask ratio (SIMD on/off) 0.078x (92.2% faster)
Image applyMask (SIMD off) 175.000 ms
Image applyMask (SIMD on) 104.000 ms
Image applyMask ratio (SIMD on/off) 0.594x (40.6% faster)
Image modifyAlpha (SIMD off) 278.000 ms
Image modifyAlpha (SIMD on) 136.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.489x (51.1% faster)
Image modifyAlpha removeColor (SIMD off) 284.000 ms
Image modifyAlpha removeColor (SIMD on) 115.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.405x (59.5% faster)
Image PNG encode (SIMD off) 1907.000 ms
Image PNG encode (SIMD on) 1397.000 ms
Image PNG encode ratio (SIMD on/off) 0.733x (26.7% faster)
Image JPEG encode 1022.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 13, 2026

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

@shai-almog shai-almog merged commit f37f09f into master May 13, 2026
21 of 22 checks 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