Skip to content

Fix #4997: guard pointerDragged against empty pointer arrays#4998

Merged
shai-almog merged 1 commit into
masterfrom
fix-4997-pointer-dragged-empty-array
May 21, 2026
Merged

Fix #4997: guard pointerDragged against empty pointer arrays#4998
shai-almog merged 1 commit into
masterfrom
fix-4997-pointer-dragged-empty-array

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • The Android port has been observed to dispatch a zero-length pointer array into Display.pointerDragged(int[], int[]). The previous code routed anything where x.length != 1 to the multi-pointer queue, so Form.pointerDragged(int[], int[]) would then dereference x[0]/y[0] and crash the EDT with ArrayIndexOutOfBoundsException: length=0; index=0 (as reported in NullPointerExceptoin in pointerDragged #4997).
  • Drop the event at the boundary in Display.pointerDragged so a malformed input from a native port can't make it onto the event queue. Guarding here keeps Form.pointerDragged untouched and stops a single bad event from propagating further.

Test plan

  • Existing JavaSE tests pass (ant test-javase / mvn test -Plocal-dev-javase).
  • Manual: simulate a Display.getInstance().pointerDragged(new int[0], new int[0]) call and confirm no exception is thrown and no event is queued.
  • Smoke-test normal single- and multi-touch drag in the simulator to confirm no regression.

Fixes #4997.

🤖 Generated with Claude Code

The Android port has been observed to dispatch zero-length pointer
arrays into Display.pointerDragged. The previous code routed any
length != 1 to the multi-pointer queue, after which Form.pointerDragged
unconditionally dereferenced x[0]/y[0] and crashed with
ArrayIndexOutOfBoundsException: length=0; index=0.

Drop the event at the boundary so a malformed input from a native
port can't bring down the EDT.

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 shai-almog merged commit 2fef718 into master May 21, 2026
15 checks passed
@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 21, 2026

Compared 110 screenshots: 110 matched.

Native Android coverage

  • 📊 Line coverage: 11.73% (6592/56180 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 9.48% (33067/348817), branch 4.11% (1363/33132), complexity 5.16% (1638/31754), method 8.98% (1332/14836), class 14.95% (302/2020)
    • 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.73% (6592/56180 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 9.48% (33067/348817), branch 4.11% (1363/33132), complexity 5.16% (1638/31754), method 8.98% (1332/14836), class 14.95% (302/2020)
    • 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 939.000 ms
Base64 CN1 encode 165.000 ms
Base64 encode ratio (CN1/native) 0.176x (82.4% faster)
Base64 native decode 1009.000 ms
Base64 CN1 decode 312.000 ms
Base64 decode ratio (CN1/native) 0.309x (69.1% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 21, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 67000 ms
Simulator Boot (Run) 1000 ms
App Install 13000 ms
App Launch 9000 ms
Test Execution 295000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 713.000 ms
Base64 CN1 encode 1269.000 ms
Base64 encode ratio (CN1/native) 1.780x (78.0% slower)
Base64 native decode 351.000 ms
Base64 CN1 decode 899.000 ms
Base64 decode ratio (CN1/native) 2.561x (156.1% slower)
Base64 SIMD encode 396.000 ms
Base64 encode ratio (SIMD/native) 0.555x (44.5% faster)
Base64 encode ratio (SIMD/CN1) 0.312x (68.8% faster)
Base64 SIMD decode 538.000 ms
Base64 decode ratio (SIMD/native) 1.533x (53.3% slower)
Base64 decode ratio (SIMD/CN1) 0.598x (40.2% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 107.000 ms
Image createMask (SIMD on) 10.000 ms
Image createMask ratio (SIMD on/off) 0.093x (90.7% faster)
Image applyMask (SIMD off) 174.000 ms
Image applyMask (SIMD on) 71.000 ms
Image applyMask ratio (SIMD on/off) 0.408x (59.2% faster)
Image modifyAlpha (SIMD off) 180.000 ms
Image modifyAlpha (SIMD on) 69.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.383x (61.7% faster)
Image modifyAlpha removeColor (SIMD off) 225.000 ms
Image modifyAlpha removeColor (SIMD on) 108.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.480x (52.0% faster)
Image PNG encode (SIMD off) 1072.000 ms
Image PNG encode (SIMD on) 1276.000 ms
Image PNG encode ratio (SIMD on/off) 1.190x (19.0% slower)
Image JPEG encode 725.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 21, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 94000 ms
Simulator Boot (Run) 1000 ms
App Install 14000 ms
App Launch 18000 ms
Test Execution 326000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1069.000 ms
Base64 CN1 encode 2384.000 ms
Base64 encode ratio (CN1/native) 2.230x (123.0% slower)
Base64 native decode 331.000 ms
Base64 CN1 decode 1351.000 ms
Base64 decode ratio (CN1/native) 4.082x (308.2% slower)
Base64 SIMD encode 532.000 ms
Base64 encode ratio (SIMD/native) 0.498x (50.2% faster)
Base64 encode ratio (SIMD/CN1) 0.223x (77.7% faster)
Base64 SIMD decode 707.000 ms
Base64 decode ratio (SIMD/native) 2.136x (113.6% slower)
Base64 decode ratio (SIMD/CN1) 0.523x (47.7% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 319.000 ms
Image createMask (SIMD on) 12.000 ms
Image createMask ratio (SIMD on/off) 0.038x (96.2% faster)
Image applyMask (SIMD off) 157.000 ms
Image applyMask (SIMD on) 72.000 ms
Image applyMask ratio (SIMD on/off) 0.459x (54.1% faster)
Image modifyAlpha (SIMD off) 419.000 ms
Image modifyAlpha (SIMD on) 221.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.527x (47.3% faster)
Image modifyAlpha removeColor (SIMD off) 652.000 ms
Image modifyAlpha removeColor (SIMD on) 221.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.339x (66.1% faster)
Image PNG encode (SIMD off) 1586.000 ms
Image PNG encode (SIMD on) 1410.000 ms
Image PNG encode ratio (SIMD on/off) 0.889x (11.1% faster)
Image JPEG encode 771.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.

NullPointerExceptoin in pointerDragged

1 participant