Skip to content

isMaxLengthSupported() answered "supported" when the platform imposed no limit - #5670

Merged
shai-almog merged 1 commit into
masterfrom
fix-video-capture-maxlength-supported
Sep 2, 2026
Merged

shai-almog merged 1 commit into
masterfrom
fix-video-capture-maxlength-supported

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

VideoCaptureConstraints.isMaxLengthSupported() guarded on the resolved length where its three siblings guard on the preferred one:

predicate first clause
isQualitySupported() preferredQuality == 0
isMaxFileSizeSupported() preferredMaxFileSize == 0
isSizeSupported() preferredWidth == 0 && preferredHeight == 0
isMaxLengthSupported() maxLength == 0 ⚠️

That clause means "the caller asked for no constraint, so any resolved value satisfies it". Read off the resolved field it fires in the opposite situation instead: a platform that expresses no duration limit by resolving maxLength to 0 — every platform with no compiler registered, Java SE included, plus any compiler that declines the request — turned a five-second preference into isMaxLengthSupported() == true, and isSupported() with it. A caller asking whether its limit would be honored was told yes precisely when the answer was no.

It also broke the invariant getMaxLength() documents: "This value will be equal to getPreferredMaxLength() iff isMaxLengthSupported() is true."

When the caller genuinely asked for no limit, preferredMaxLength and maxLength are both 0, so the new clause covers that case identically. The clause only ever changed the answer in the broken case.

Blast radius

No framework caller reads the predicate (the only references are the developer guide's snippet and a generated reflection shim), and no test asserted the old behaviour, so nothing depended on it.

Verification

  • The new testMaxLengthUnsupportedWhenResolvedToZero fails on the unfixed code (expected: <false> but was: <true>) and passes after — the other two new cases pass either way, which is what isolates the defect to this one clause.
  • Full core-unittests suite: 6077 tests, 0 failures.
  • SpotBugs over core-unittests: report regenerated, 0 findings.

Found by Codex review on #5664, where the guide chapter documents this API.

🤖 Generated with Claude Code

… no limit

The predicate guarded on the RESOLVED length where its three siblings guard on
the PREFERRED one:

    isQualitySupported()     preferredQuality == 0     || quality == preferredQuality
    isMaxFileSizeSupported() preferredMaxFileSize == 0 || maxFileSize == preferredMaxFileSize
    isSizeSupported()        preferredWidth == 0 && preferredHeight == 0
    isMaxLengthSupported()   maxLength == 0            || maxLength == preferredMaxLength

The intent of that first clause is "the caller asked for no constraint, so any
resolved value satisfies it". Reading it off the resolved field makes it fire in
the opposite situation: a platform that expresses "no duration limit" by
resolving maxLength to 0 -- which is every platform with no compiler registered,
Java SE included, and any compiler that declines the request -- turned a
five-second preference into isMaxLengthSupported() == true, and isSupported()
with it. A caller asking whether its limit would be honored was told yes
precisely when the answer was no.

That also broke the invariant getMaxLength() documents: "This value will be
equal to getPreferredMaxLength() iff isMaxLengthSupported() is true."

When the caller asked for no limit, preferredMaxLength and maxLength are both 0,
so the new clause covers that case identically. The clause only ever changed the
answer in the broken case.

No framework caller reads the predicate, and no test asserted the old behaviour,
so nothing depended on it. The developer guide's Video-Capture-Constraints
example already describes the fixed semantics, and its support table already
lists Java SE as having no max-length support.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-02T11:26:58.417060Z fb5b823 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@shai-almog

shai-almog commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 151 screenshots: 151 matched.

Native Android coverage

  • 📊 Line coverage: 9.10% (9017/99118 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.88% (46522/523733), branch 3.50% (1739/49629), complexity 3.48% (1842/52924), method 5.34% (1487/27841), class 10.74% (400/3723)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6367 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.ClassReader – 0.00% (0/1524 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1187 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.MethodWriter – 0.00% (0/922 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/736 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • okio.okio.Buffer – 0.00% (0/687 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/625 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.Frame – 0.00% (0/570 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 9.10% (9017/99118 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.88% (46522/523733), branch 3.50% (1739/49629), complexity 3.48% (1842/52924), method 5.34% (1487/27841), class 10.74% (400/3723)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6367 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.ClassReader – 0.00% (0/1524 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1187 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.MethodWriter – 0.00% (0/922 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/736 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • okio.okio.Buffer – 0.00% (0/687 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/625 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.Frame – 0.00% (0/570 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend scalar fallback (no native SIMD)
SIMD int-add (64K x300) java 302ms / native 219ms = 1.3x speedup
SIMD float-mul (64K x300) java 193ms / native 165ms = 1.1x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 74.000 ms
Base64 CN1 decode 85.000 ms
Base64 native encode 329.000 ms
Base64 encode ratio (CN1/native) 0.225x (77.5% faster)
Base64 native decode 265.000 ms
Base64 decode ratio (CN1/native) 0.321x (67.9% faster)
Image encode benchmark status skipped (SIMD unsupported)

@github-actions

github-actions Bot commented Sep 2, 2026

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)
    • ✅ build-hint-catalog: 0 findings (no issues)
    • ✅ build-hint-tools: 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

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog
shai-almog merged commit 045d113 into master Sep 2, 2026
29 checks passed
@shai-almog
shai-almog deleted the fix-video-capture-maxlength-supported branch September 2, 2026 11:55
@shai-almog

shai-almog commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

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

@shai-almog

shai-almog commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 148 screenshots: 148 matched.
✅ Native Mac screenshot tests passed.

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 63ms / native 5ms = 12.6x speedup
SIMD float-mul (64K x300) java 57ms / native 3ms = 19.0x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 186.000 ms
Base64 CN1 decode 112.000 ms
Base64 native encode 823.000 ms
Base64 encode ratio (CN1/native) 0.226x (77.4% faster)
Base64 native decode 251.000 ms
Base64 decode ratio (CN1/native) 0.446x (55.4% faster)
Base64 SIMD encode 60.000 ms
Base64 encode ratio (SIMD/CN1) 0.323x (67.7% faster)
Base64 SIMD decode 45.000 ms
Base64 decode ratio (SIMD/CN1) 0.402x (59.8% faster)
Base64 encode ratio (SIMD/native) 0.073x (92.7% faster)
Base64 decode ratio (SIMD/native) 0.179x (82.1% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 9.000 ms
Image createMask (SIMD on) 7.000 ms
Image createMask ratio (SIMD on/off) 0.778x (22.2% faster)
Image applyMask (SIMD off) 59.000 ms
Image applyMask (SIMD on) 65.000 ms
Image applyMask ratio (SIMD on/off) 1.102x (10.2% slower)
Image modifyAlpha (SIMD off) 54.000 ms
Image modifyAlpha (SIMD on) 42.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.778x (22.2% faster)
Image modifyAlpha removeColor (SIMD off) 57.000 ms
Image modifyAlpha removeColor (SIMD on) 46.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.807x (19.3% faster)

@shai-almog

shai-almog commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 160 screenshots: 160 matched.
✅ Native Mac screenshot tests passed.

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 77ms / native 5ms = 15.4x speedup
SIMD float-mul (64K x300) java 83ms / native 3ms = 27.6x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 172.000 ms
Base64 CN1 decode 105.000 ms
Image encode benchmark iterations 100
Image createMask (SIMD off) 6.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.333x (66.7% faster)
Image applyMask (SIMD off) 55.000 ms
Image applyMask (SIMD on) 40.000 ms
Image applyMask ratio (SIMD on/off) 0.727x (27.3% faster)
Image modifyAlpha (SIMD off) 45.000 ms
Image modifyAlpha (SIMD on) 40.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.889x (11.1% faster)
Image modifyAlpha removeColor (SIMD off) 47.000 ms
Image modifyAlpha removeColor (SIMD on) 48.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.021x (2.1% slower)

@shai-almog

shai-almog commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 123000 ms
Simulator Boot (Run) 1000 ms
App Install 21000 ms
App Launch 4000 ms
Test Execution 582000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 75ms / native 4ms = 18.7x speedup
SIMD float-mul (64K x300) java 131ms / native 3ms = 43.6x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 715.000 ms
Base64 CN1 decode 209.000 ms
Base64 native encode 1316.000 ms
Base64 encode ratio (CN1/native) 0.543x (45.7% faster)
Base64 native decode 2221.000 ms
Base64 decode ratio (CN1/native) 0.094x (90.6% faster)
Base64 SIMD encode 434.000 ms
Base64 encode ratio (SIMD/CN1) 0.607x (39.3% faster)
Base64 SIMD decode 116.000 ms
Base64 decode ratio (SIMD/CN1) 0.555x (44.5% faster)
Base64 encode ratio (SIMD/native) 0.330x (67.0% faster)
Base64 decode ratio (SIMD/native) 0.052x (94.8% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 15.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.133x (86.7% faster)
Image applyMask (SIMD off) 103.000 ms
Image applyMask (SIMD on) 208.000 ms
Image applyMask ratio (SIMD on/off) 2.019x (101.9% slower)
Image modifyAlpha (SIMD off) 55.000 ms
Image modifyAlpha (SIMD on) 109.000 ms
Image modifyAlpha ratio (SIMD on/off) 1.982x (98.2% slower)
Image modifyAlpha removeColor (SIMD off) 58.000 ms
Image modifyAlpha removeColor (SIMD on) 186.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 3.207x (220.7% slower)

@shai-almog

shai-almog commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 144 screenshots: 144 matched.
✅ Native Apple TV (tvOS, Metal) screenshot tests passed.

@shai-almog

shai-almog commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 84000 ms
Simulator Boot (Run) 1000 ms
App Install 36000 ms
App Launch 3000 ms
Test Execution 572000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 81ms / native 6ms = 13.5x speedup
SIMD float-mul (64K x300) java 135ms / native 3ms = 45.0x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 388.000 ms
Base64 CN1 decode 156.000 ms
Base64 native encode 568.000 ms
Base64 encode ratio (CN1/native) 0.683x (31.7% faster)
Base64 native decode 428.000 ms
Base64 decode ratio (CN1/native) 0.364x (63.6% faster)
Base64 SIMD encode 125.000 ms
Base64 encode ratio (SIMD/CN1) 0.322x (67.8% faster)
Base64 SIMD decode 88.000 ms
Base64 decode ratio (SIMD/CN1) 0.564x (43.6% faster)
Base64 encode ratio (SIMD/native) 0.220x (78.0% faster)
Base64 decode ratio (SIMD/native) 0.206x (79.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 8.000 ms
Image createMask (SIMD on) 1.000 ms
Image createMask ratio (SIMD on/off) 0.125x (87.5% faster)
Image applyMask (SIMD off) 55.000 ms
Image applyMask (SIMD on) 39.000 ms
Image applyMask ratio (SIMD on/off) 0.709x (29.1% faster)
Image modifyAlpha (SIMD off) 61.000 ms
Image modifyAlpha (SIMD on) 74.000 ms
Image modifyAlpha ratio (SIMD on/off) 1.213x (21.3% slower)
Image modifyAlpha removeColor (SIMD off) 69.000 ms
Image modifyAlpha removeColor (SIMD on) 45.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.652x (34.8% faster)

@shai-almog

shai-almog commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 217 screenshots: 217 matched.
✅ Native Apple Watch (watchOS, Core Graphics) screenshot tests 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