Skip to content

Add pluggable AnimationTime clock for animations#4816

Merged
liannacasper merged 2 commits into
masterfrom
feature/animation-time-clock
Apr 26, 2026
Merged

Add pluggable AnimationTime clock for animations#4816
liannacasper merged 2 commits into
masterfrom
feature/animation-time-clock

Conversation

@liannacasper
Copy link
Copy Markdown
Collaborator

Summary

  • New final AnimationTime class in com.codename1.ui.animations with a static now() / setTime(long) / reset() / isOverridden() API. Defaults to System.currentTimeMillis(); when overridden, now() returns the explicit value until reset(). Primitive-only state (one long, one boolean) to keep the hot path cheap.
  • Routes all animation-related clock reads through it: Motion (start/finish/getCurrentMotionTime/createDecelerationMotionFrom), Timeline (setTime/animate), Container.MorphAnimation, Image.animate(), and Label text ticker.
  • Lets users drive animations deterministically (UI tests), slow them down, fast-forward, or step frame-by-frame — without relying on the Motion.slowMotion hack as the only lever.

Non-animation System.currentTimeMillis() call sites (Display transition lock-wait, gesture/tap detection in Switch/MapComponent/Spinner, UITimer, etc.) are intentionally left alone.

Test plan

  • mvn -pl core compile — 702 sources, BUILD SUCCESS
  • New AnimationTimeTest (8 cases) covers the static API plus integration assertions that Motion.start()/finish()/getCurrentMotionTime()/getValue()/isFinished() and Timeline.animate() honor the override
  • Full com.codename1.ui.animations.*Test suite — 35/35 green (8 new + 27 pre-existing untouched)

🤖 Generated with Claude Code

Introduces a final AnimationTime class with a static now()/setTime/reset
API that defaults to System.currentTimeMillis() but can be overridden with
an explicit value. Routes Motion, Timeline, MorphAnimation, Image.animate
and Label tickers through it so animations can be driven deterministically
for tests, slow-motion, fast-forward, or manual frame stepping — without
the previous Motion.slowMotion hack being the only lever.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 26, 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

shai-almog commented Apr 26, 2026

Compared 37 screenshots: 37 matched.

Native Android coverage

  • 📊 Line coverage: 7.91% (4197/53043 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.20% (20693/333558), branch 3.03% (975/32174), complexity 3.69% (1136/30766), method 6.49% (931/14344), class 10.63% (202/1900)
    • 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: 7.91% (4197/53043 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.20% (20693/333558), branch 3.03% (975/32174), complexity 3.69% (1136/30766), method 6.49% (931/14344), class 10.63% (202/1900)
    • 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 888.000 ms
Base64 CN1 encode 234.000 ms
Base64 encode ratio (CN1/native) 0.264x (73.6% faster)
Base64 native decode 1005.000 ms
Base64 CN1 decode 198.000 ms
Base64 decode ratio (CN1/native) 0.197x (80.3% faster)
Image encode benchmark status skipped (SIMD unsupported)

Ant/javac on CI compiles with the platform default encoding (ASCII), so
the em-dash in the class-level comment failed with "unmappable character
for encoding ASCII".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@liannacasper liannacasper merged commit 3808d78 into master Apr 26, 2026
15 checks passed
@shai-almog
Copy link
Copy Markdown
Collaborator

shai-almog commented Apr 26, 2026

iOS screenshot updates

Compared 35 screenshots: 33 matched, 1 updated, 1 error.

  • graphics-scale — comparison error. Comparison error: PNG chunk truncated before CRC while processing: /Users/runner/work/_temp/cn1-ios-tests-0GGcGH/graphics-scale.png

    No preview available for this screenshot.
    Full-resolution PNG saved as graphics-scale.png in workflow artifacts.

  • landscape — updated screenshot. Screenshot differs (2556x1179 px, bit depth 8).

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 57000 ms
Simulator Boot (Run) 2000 ms
App Install 27000 ms
App Launch 9000 ms
Test Execution 160000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1116.000 ms
Base64 CN1 encode 1943.000 ms
Base64 encode ratio (CN1/native) 1.741x (74.1% slower)
Base64 native decode 806.000 ms
Base64 CN1 decode 1147.000 ms
Base64 decode ratio (CN1/native) 1.423x (42.3% slower)
Base64 SIMD encode 669.000 ms
Base64 encode ratio (SIMD/native) 0.599x (40.1% faster)
Base64 encode ratio (SIMD/CN1) 0.344x (65.6% faster)
Base64 SIMD decode 452.000 ms
Base64 decode ratio (SIMD/native) 0.561x (43.9% faster)
Base64 decode ratio (SIMD/CN1) 0.394x (60.6% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 78.000 ms
Image createMask (SIMD on) 14.000 ms
Image createMask ratio (SIMD on/off) 0.179x (82.1% faster)
Image applyMask (SIMD off) 153.000 ms
Image applyMask (SIMD on) 49.000 ms
Image applyMask ratio (SIMD on/off) 0.320x (68.0% faster)
Image modifyAlpha (SIMD off) 148.000 ms
Image modifyAlpha (SIMD on) 69.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.466x (53.4% faster)
Image modifyAlpha removeColor (SIMD off) 249.000 ms
Image modifyAlpha removeColor (SIMD on) 77.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.309x (69.1% faster)
Image PNG encode (SIMD off) 1120.000 ms
Image PNG encode (SIMD on) 901.000 ms
Image PNG encode ratio (SIMD on/off) 0.804x (19.6% faster)
Image JPEG encode 608.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