Skip to content

Fix CI flake: JavaSEPortFontMappingTest leaks JavaSEPort.instance#5063

Merged
liannacasper merged 1 commit into
masterfrom
fix-javaseport-instance-leak
May 28, 2026
Merged

Fix CI flake: JavaSEPortFontMappingTest leaks JavaSEPort.instance#5063
liannacasper merged 1 commit into
masterfrom
fix-javaseport-instance-leak

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • JavaSEPortFontMappingTest constructs new JavaSEPort() inside two tests, and the constructor unconditionally assigns instance = this, so the throwaway port leaks into the global static.
  • If CodenameOneExtensionTest runs in the same JVM after Display has already been initialized (e.g. by PaintScopeTest), the extension's @LargerText / @Orientation handling mutates the wrong port via JavaSEPort.instance while Display.impl still references the original — assertions then read stale defaults (1.0 / landscape).
  • Order-dependent latent flake (not caused by any recent change): master's 04:52 run discovered CodenameOneExtensionTest first and passed; the 07:33 PR run picked the failing interleaving and surfaced two failures.

Fix: capture JavaSEPort.instance in @BeforeEach and restore it in @AfterEach so this test no longer leaks across test classes. It is the only test in the repo that constructs new JavaSEPort(), so this single change closes the flake.

Test plan

  • mvn -pl javase test -Plocal-dev-javase — all 70 tests pass.
  • Synthetic reproducer (init Display, construct new JavaSEPort(), run CodenameOneExtensionTest) reproduced the CI failure verbatim before the fix.
  • Same reproducer driving JavaSEPortFontMappingTest's @BeforeEach/@AfterEach passes with the fix.

🤖 Generated with Claude Code

JavaSEPortFontMappingTest constructs `new JavaSEPort()` inside two of
its tests; the JavaSEPort constructor unconditionally assigns
`instance = this`, so the throwaway port leaks into the global static.
If CodenameOneExtensionTest then runs in the same JVM after Display has
already been initialized (e.g. by PaintScopeTest), the extension's
@LargerText / @orientation handling mutates the wrong port via
JavaSEPort.instance while Display.impl still references the original,
and the assertions read stale defaults.

The bug is order-dependent: master's recent CI runs happened to pick a
test order where CodenameOneExtensionTest ran first, so the leak was
masked; PR runs that interleaved PaintScopeTest, FontMappingTest, and
CodenameOneExtensionTest in the failing order surfaced it as two test
failures ("expected: <1.6> but was: <1.0>", "expected: <true> but was:
<false>").

Capture JavaSEPort.instance in @beforeeach and restore it in @AfterEach
so the test no longer leaks across test classes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@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 28, 2026

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

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 28, 2026

Compared 116 screenshots: 116 matched.

Native Android coverage

  • 📊 Line coverage: 12.42% (7198/57972 lines covered) (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.13% (36195/357360), branch 4.24% (1435/33836), complexity 5.29% (1717/32486), method 9.25% (1407/15210), class 15.16% (321/2117)
    • 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: 12.42% (7198/57972 lines covered) (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.13% (36195/357360), branch 4.24% (1435/33836), complexity 5.29% (1717/32486), method 9.25% (1407/15210), class 15.16% (321/2117)
    • 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 828.000 ms
Base64 CN1 encode 232.000 ms
Base64 encode ratio (CN1/native) 0.280x (72.0% faster)
Base64 native decode 963.000 ms
Base64 CN1 decode 206.000 ms
Base64 decode ratio (CN1/native) 0.214x (78.6% faster)
Image encode benchmark status skipped (SIMD unsupported)

@liannacasper liannacasper merged commit a3d7a92 into master May 28, 2026
19 checks passed
@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 28, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 97000 ms
Simulator Boot (Run) 1000 ms
App Install 12000 ms
App Launch 9000 ms
Test Execution 339000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1037.000 ms
Base64 CN1 encode 2368.000 ms
Base64 encode ratio (CN1/native) 2.284x (128.4% slower)
Base64 native decode 547.000 ms
Base64 CN1 decode 1392.000 ms
Base64 decode ratio (CN1/native) 2.545x (154.5% slower)
Base64 SIMD encode 618.000 ms
Base64 encode ratio (SIMD/native) 0.596x (40.4% faster)
Base64 encode ratio (SIMD/CN1) 0.261x (73.9% faster)
Base64 SIMD decode 637.000 ms
Base64 decode ratio (SIMD/native) 1.165x (16.5% slower)
Base64 decode ratio (SIMD/CN1) 0.458x (54.2% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 122.000 ms
Image createMask (SIMD on) 15.000 ms
Image createMask ratio (SIMD on/off) 0.123x (87.7% faster)
Image applyMask (SIMD off) 291.000 ms
Image applyMask (SIMD on) 125.000 ms
Image applyMask ratio (SIMD on/off) 0.430x (57.0% faster)
Image modifyAlpha (SIMD off) 215.000 ms
Image modifyAlpha (SIMD on) 98.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.456x (54.4% faster)
Image modifyAlpha removeColor (SIMD off) 239.000 ms
Image modifyAlpha removeColor (SIMD on) 112.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.469x (53.1% faster)
Image PNG encode (SIMD off) 1716.000 ms
Image PNG encode (SIMD on) 1269.000 ms
Image PNG encode ratio (SIMD on/off) 0.740x (26.0% faster)
Image JPEG encode 753.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 28, 2026

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

Benchmark Results

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

Build and Run Timing

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

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 628.000 ms
Base64 CN1 encode 1485.000 ms
Base64 encode ratio (CN1/native) 2.365x (136.5% slower)
Base64 native decode 276.000 ms
Base64 CN1 decode 983.000 ms
Base64 decode ratio (CN1/native) 3.562x (256.2% slower)
Base64 SIMD encode 420.000 ms
Base64 encode ratio (SIMD/native) 0.669x (33.1% faster)
Base64 encode ratio (SIMD/CN1) 0.283x (71.7% faster)
Base64 SIMD decode 379.000 ms
Base64 decode ratio (SIMD/native) 1.373x (37.3% slower)
Base64 decode ratio (SIMD/CN1) 0.386x (61.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 57.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.158x (84.2% faster)
Image applyMask (SIMD off) 121.000 ms
Image applyMask (SIMD on) 62.000 ms
Image applyMask ratio (SIMD on/off) 0.512x (48.8% faster)
Image modifyAlpha (SIMD off) 141.000 ms
Image modifyAlpha (SIMD on) 62.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.440x (56.0% faster)
Image modifyAlpha removeColor (SIMD off) 147.000 ms
Image modifyAlpha removeColor (SIMD on) 66.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.449x (55.1% faster)
Image PNG encode (SIMD off) 1159.000 ms
Image PNG encode (SIMD on) 996.000 ms
Image PNG encode ratio (SIMD on/off) 0.859x (14.1% faster)
Image JPEG encode 406.000 ms

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.

2 participants