Skip to content

iOS: add ios.metal.colorSpace build hint for the Metal renderer#4909

Merged
shai-almog merged 1 commit intomasterfrom
ios-metal-colorspace-hint
May 10, 2026
Merged

iOS: add ios.metal.colorSpace build hint for the Metal renderer#4909
shai-almog merged 1 commit intomasterfrom
ios-metal-colorspace-hint

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

@shai-almog shai-almog commented May 10, 2026

Summary

  • Adds an ios.metal.colorSpace build hint that lets apps pick the CAMetalLayer colour space instead of being stuck with the hard-coded sRGB choice (issue partial transparency persists, even to new frame drawing events. #4908).
  • METALView.m now selects the colorspace from a compile-time CN1_METAL_COLORSPACE_* define and falls back to sRGB so existing builds are unchanged.
  • IPhoneBuilder reads the hint when ios.metal=true and rewrites a placeholder line in CN1ES2compat.h. Accepted values: sRGB (default), displayP3, deviceRGB, linearSRGB, extendedSRGB, extendedLinearSRGB, none (leaves the layer's colorspace unset).
  • New section in docs/developer-guide/Working-With-iOS.asciidoc documents the values.

Companion change for the build server: codenameone/BuildDaemon#73.

Test plan

  • Build an iOS app with ios.metal=true and no colour-space hint — visual output unchanged from the previous sRGB-only behaviour.
  • Build with ios.metal=true and ios.metal.colorSpace=displayP3 on a P3 device, confirm wide-gamut artwork renders with extended saturation.
  • Build with ios.metal.colorSpace=none and confirm the layer falls back to the system default without crashing.
  • Build with ios.metal=false to confirm the new code path is dormant.
  • Sanity-check an unrecognised value produces the warning log and falls back to sRGB.

🤖 Generated with Claude Code

Issue #4908 surfaces that Metal's hard-coded sRGB layer colour space is
not the right pick for every app (wide-gamut content, custom DeviceRGB
pipelines, or apps that prefer the system default).

METALView.m now selects the CAMetalLayer colorspace from a compile-time
CN1_METAL_COLORSPACE_* define and falls back to sRGB so existing builds
are unchanged. IPhoneBuilder reads the new ios.metal.colorSpace hint
(values: sRGB, displayP3, deviceRGB, linearSRGB, extendedSRGB,
extendedLinearSRGB, none) and rewrites a placeholder line in
CN1ES2compat.h with the matching define when ios.metal=true.

The same change is mirrored in the build server's IPhoneBuilder; the
developer guide gets a new section under Working with iOS describing
each value.

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

Developer Guide build artifacts are available for download from this workflow run:

Developer Guide quality checks:

  • AsciiDoc linter: No issues found (report)
  • Vale: Vale failed (exit code 2) (report)
  • Image references: 1 unused image(s) found (report)

Unused image preview:

  • img/skin-designer/.gitkeep

@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.

@github-actions
Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 10, 2026

Compared 90 screenshots: 90 matched.

Native Android coverage

  • 📊 Line coverage: 10.21% (5578/54613 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.04% (27390/340806), branch 3.68% (1201/32660), complexity 4.69% (1466/31285), method 8.25% (1206/14620), class 13.68% (269/1966)
    • 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: 10.21% (5578/54613 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.04% (27390/340806), branch 3.68% (1201/32660), complexity 4.69% (1466/31285), method 8.25% (1206/14620), class 13.68% (269/1966)
    • 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 823.000 ms
Base64 CN1 encode 167.000 ms
Base64 encode ratio (CN1/native) 0.203x (79.7% faster)
Base64 native decode 720.000 ms
Base64 CN1 decode 345.000 ms
Base64 decode ratio (CN1/native) 0.479x (52.1% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 10, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 67000 ms
Simulator Boot (Run) 0 ms
App Install 11000 ms
App Launch 5000 ms
Test Execution 251000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1073.000 ms
Base64 CN1 encode 1227.000 ms
Base64 encode ratio (CN1/native) 1.144x (14.4% slower)
Base64 native decode 767.000 ms
Base64 CN1 decode 911.000 ms
Base64 decode ratio (CN1/native) 1.188x (18.8% slower)
Base64 SIMD encode 402.000 ms
Base64 encode ratio (SIMD/native) 0.375x (62.5% faster)
Base64 encode ratio (SIMD/CN1) 0.328x (67.2% faster)
Base64 SIMD decode 418.000 ms
Base64 decode ratio (SIMD/native) 0.545x (45.5% faster)
Base64 decode ratio (SIMD/CN1) 0.459x (54.1% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 59.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.153x (84.7% faster)
Image applyMask (SIMD off) 157.000 ms
Image applyMask (SIMD on) 151.000 ms
Image applyMask ratio (SIMD on/off) 0.962x (3.8% faster)
Image modifyAlpha (SIMD off) 128.000 ms
Image modifyAlpha (SIMD on) 84.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.656x (34.4% faster)
Image modifyAlpha removeColor (SIMD off) 143.000 ms
Image modifyAlpha removeColor (SIMD on) 85.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.594x (40.6% faster)
Image PNG encode (SIMD off) 948.000 ms
Image PNG encode (SIMD on) 803.000 ms
Image PNG encode ratio (SIMD on/off) 0.847x (15.3% faster)
Image JPEG encode 474.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 10, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 59000 ms
Simulator Boot (Run) 0 ms
App Install 12000 ms
App Launch 4000 ms
Test Execution 201000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1022.000 ms
Base64 CN1 encode 1177.000 ms
Base64 encode ratio (CN1/native) 1.152x (15.2% slower)
Base64 native decode 672.000 ms
Base64 CN1 decode 869.000 ms
Base64 decode ratio (CN1/native) 1.293x (29.3% slower)
Base64 SIMD encode 377.000 ms
Base64 encode ratio (SIMD/native) 0.369x (63.1% faster)
Base64 encode ratio (SIMD/CN1) 0.320x (68.0% faster)
Base64 SIMD decode 372.000 ms
Base64 decode ratio (SIMD/native) 0.554x (44.6% faster)
Base64 decode ratio (SIMD/CN1) 0.428x (57.2% 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) 120.000 ms
Image applyMask (SIMD on) 51.000 ms
Image applyMask ratio (SIMD on/off) 0.425x (57.5% faster)
Image modifyAlpha (SIMD off) 119.000 ms
Image modifyAlpha (SIMD on) 51.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.429x (57.1% faster)
Image modifyAlpha removeColor (SIMD off) 172.000 ms
Image modifyAlpha removeColor (SIMD on) 70.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.407x (59.3% faster)
Image PNG encode (SIMD off) 946.000 ms
Image PNG encode (SIMD on) 872.000 ms
Image PNG encode ratio (SIMD on/off) 0.922x (7.8% faster)
Image JPEG encode 428.000 ms

@shai-almog shai-almog merged commit aa19520 into master May 10, 2026
24 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