Skip to content

Fix #5014: roll back default-date staging when Picker is cancelled on first open#5017

Merged
shai-almog merged 1 commit into
masterfrom
fix-5014-picker-cancel-default-date
May 23, 2026
Merged

Fix #5014: roll back default-date staging when Picker is cancelled on first open#5017
shai-almog merged 1 commit into
masterfrom
fix-5014-picker-cancel-default-date

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Picker: default value is incorrectly set as new value when user taps Cancel (only on first use) #5014: with Picker.setDefaultDate(...) installed, tapping the picker and pressing Cancel on the first open was leaking the resolved default into value, flipping the displayed text from "..." to today's date and making getDate() return as if the user had committed. Re-opening then dismissing worked correctly because the second snapshot already held a "real" value.
  • Root cause: actionPerformed calls applyDefaultDateIfNeeded() (which mutates value to the resolved default) before showInteractionDialog's Cancel-restore snapshot ran — so the snapshot captured the post-staging value and Cancel "restored" it back to itself. Same silent leak existed in the native picker and synchronous heavyweight Dialog cancel paths.
  • Take the snapshot in actionPerformed before applyDefaultDateIfNeeded(). Remove the now-redundant snapshot from showInteractionDialog. Add matching cancel-time rollback to the native branch and to PICKER_TYPE_DATE / PICKER_TYPE_DATE_AND_TIME cases in the heavyweight Dialog else branch.
  • The existing custom-button rollback path (RFE: Add method to Picker to get or update internal value based on the Picker scroll wheel positions set by the user #4897 / cancelAfterCustomButtonRollsBackExplicitFlag) continues to work because both snapshots are now sourced from the same earlier capture.

Test plan

  • New JUnit regression PickerDefaultDateTest#cancelOnFirstOpenKeepsPlaceholderAndDoesNotPinValue mirroring the repro: setDefaultDate(getter)setType(DATE)setDate(null) → tap → Cancel; asserts getText() is still "..." and that subsequent getDate() resolves through an updated getter (i.e. nothing was pinned).
  • PickerDefaultDateTest — 11/11 pass (10 pre-existing + 1 new).
  • All 30 picker tests pass: PickerComponentTest (5), PickerDefaultDateTest (11), PickerTest (2), Picker3Test (1), PickerCoverageTest (10), PickerDateTimeTest (1).
  • Manual smoke-test on a real device / simulator with the issue repro (lightweight popup is the iOS default; bug should also be gone on the native Android picker path covered by the same fix).

🤖 Generated with Claude Code

… first open

The default-date support added in RFE #4973 stages the resolved default
into Picker.value via applyDefaultDateIfNeeded() so the show paths can
display it. The Cancel-restore snapshot in showInteractionDialog ran
*after* that staging, so a Cancel on the first open restored the leaked
default into value - flipping the picker text from "..." to today's date
and making subsequent getDate() / setDate(null) behavior look as if the
user had committed. The same leak existed silently in the native picker
and synchronous heavyweight Dialog branches.

Take the snapshot in actionPerformed before applyDefaultDateIfNeeded
runs, and add the matching cancel-time rollback in the native picker
branch and the heavyweight Dialog PICKER_TYPE_DATE / DATE_AND_TIME
cases. The existing custom-button cancel rollback (#4897) still works
because both snapshots are now sourced from the same earlier capture.

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 23, 2026

Compared 110 screenshots: 110 matched.

Native Android coverage

  • 📊 Line coverage: 11.90% (6755/56788 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 9.67% (33991/351672), branch 4.16% (1389/33359), complexity 5.20% (1664/32007), method 9.04% (1354/14973), class 14.72% (302/2051)
    • 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.90% (6755/56788 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 9.67% (33991/351672), branch 4.16% (1389/33359), complexity 5.20% (1664/32007), method 9.04% (1354/14973), class 14.72% (302/2051)
    • 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 1174.000 ms
Base64 CN1 encode 203.000 ms
Base64 encode ratio (CN1/native) 0.173x (82.7% faster)
Base64 native decode 665.000 ms
Base64 CN1 decode 212.000 ms
Base64 decode ratio (CN1/native) 0.319x (68.1% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 23, 2026

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

Benchmark Results

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

Build and Run Timing

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

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 571.000 ms
Base64 CN1 encode 1399.000 ms
Base64 encode ratio (CN1/native) 2.450x (145.0% slower)
Base64 native decode 392.000 ms
Base64 CN1 decode 929.000 ms
Base64 decode ratio (CN1/native) 2.370x (137.0% slower)
Base64 SIMD encode 382.000 ms
Base64 encode ratio (SIMD/native) 0.669x (33.1% faster)
Base64 encode ratio (SIMD/CN1) 0.273x (72.7% faster)
Base64 SIMD decode 366.000 ms
Base64 decode ratio (SIMD/native) 0.934x (6.6% faster)
Base64 decode ratio (SIMD/CN1) 0.394x (60.6% 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) 122.000 ms
Image applyMask (SIMD on) 55.000 ms
Image applyMask ratio (SIMD on/off) 0.451x (54.9% faster)
Image modifyAlpha (SIMD off) 121.000 ms
Image modifyAlpha (SIMD on) 62.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.512x (48.8% faster)
Image modifyAlpha removeColor (SIMD off) 153.000 ms
Image modifyAlpha removeColor (SIMD on) 129.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.843x (15.7% faster)
Image PNG encode (SIMD off) 1853.000 ms
Image PNG encode (SIMD on) 866.000 ms
Image PNG encode ratio (SIMD on/off) 0.467x (53.3% faster)
Image JPEG encode 490.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 23, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 101000 ms
Simulator Boot (Run) 2000 ms
App Install 19000 ms
App Launch 5000 ms
Test Execution 284000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 624.000 ms
Base64 CN1 encode 1236.000 ms
Base64 encode ratio (CN1/native) 1.981x (98.1% slower)
Base64 native decode 286.000 ms
Base64 CN1 decode 844.000 ms
Base64 decode ratio (CN1/native) 2.951x (195.1% slower)
Base64 SIMD encode 370.000 ms
Base64 encode ratio (SIMD/native) 0.593x (40.7% faster)
Base64 encode ratio (SIMD/CN1) 0.299x (70.1% faster)
Base64 SIMD decode 365.000 ms
Base64 decode ratio (SIMD/native) 1.276x (27.6% slower)
Base64 decode ratio (SIMD/CN1) 0.432x (56.8% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 55.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.164x (83.6% faster)
Image applyMask (SIMD off) 121.000 ms
Image applyMask (SIMD on) 50.000 ms
Image applyMask ratio (SIMD on/off) 0.413x (58.7% faster)
Image modifyAlpha (SIMD off) 159.000 ms
Image modifyAlpha (SIMD on) 59.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.371x (62.9% faster)
Image modifyAlpha removeColor (SIMD off) 177.000 ms
Image modifyAlpha removeColor (SIMD on) 79.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.446x (55.4% faster)
Image PNG encode (SIMD off) 1093.000 ms
Image PNG encode (SIMD on) 2250.000 ms
Image PNG encode ratio (SIMD on/off) 2.059x (105.9% slower)
Image JPEG encode 462.000 ms

@shai-almog shai-almog merged commit d08af01 into master May 23, 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.

Picker: default value is incorrectly set as new value when user taps Cancel (only on first use)

1 participant