Skip to content

fix(avc): align scaled capture dimensions to encoder alignment - #42

Merged
gmegidish merged 1 commit into
mainfrom
fix/avc-dimension-alignment
Aug 20, 2026
Merged

fix(avc): align scaled capture dimensions to encoder alignment#42
gmegidish merged 1 commit into
mainfrom
fix/avc-dimension-alignment

Conversation

@gmegidish

@gmegidish gmegidish commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

(display * scale).toInt() can produce odd dimensions — Pixel 10 Pro's 1080x2410 display at scale 0.5 yields 540x1205 — which isSizeSupported() rejects, killing the capture before any frame with the misleading "exceed codec capabilities. Maximum supported: 3840x3840" error. In production this makes WebRTC streaming fail 100% of the time on any device model whose scaled height is odd (verified live on a farm Pixel 10 Pro: scale 0.50 always fails, scale 0.48 with even dims streams fine).

Fix: query the encoder's widthAlignment/heightAlignment (min 2) and round each scaled dimension down to it before validating/configuring.

(display * scale).toInt() can produce odd dimensions — e.g. Pixel 10 Pro's
1080x2410 display at scale 0.5 gives 540x1205 — which isSizeSupported()
rejects, killing the capture before any frame with a misleading 'exceed
codec capabilities' error. Round each dimension down to the codec's own
width/height alignment (min 2) before validating.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 74cc9b00-23b7-41ab-9946-6fb4ad24eb5f

📥 Commits

Reviewing files that changed from the base of the PR and between 7976626 and ec7c8d3.

📒 Files selected for processing (1)
  • app/src/main/java/com/mobilenext/devicekit/AvcServer.kt

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Walkthrough

streamAvcFrames now creates the AVC codec before calculating scaled dimensions. It reads the codec alignment requirements and rounds scaled width and height down to compatible values. If the resulting dimensions are invalid, it releases the codec before throwing an exception. The previous warning for odd dimensions was removed.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: aligning scaled AVC capture dimensions with encoder requirements.
Description check ✅ Passed The description explains the odd-dimension failure and the encoder-alignment fix, which directly matches the changeset.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/avc-dimension-alignment

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@gmegidish
gmegidish merged commit b753c38 into main Aug 20, 2026
8 checks passed
@gmegidish
gmegidish deleted the fix/avc-dimension-alignment branch August 20, 2026 12:58
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