Skip to content

(fix) flutter: fix camera preview for YUYV-only devices - #87

Open
suhwanhwang wants to merge 2 commits into
alexey-pelykh:mainfrom
suhwanhwang:fix/flutter-preview-camera-init
Open

(fix) flutter: fix camera preview for YUYV-only devices#87
suhwanhwang wants to merge 2 commits into
alexey-pelykh:mainfrom
suhwanhwang:fix/flutter-preview-camera-init

Conversation

@suhwanhwang

Copy link
Copy Markdown

Summary

  • Fix getSupportedSizeList() returning empty list during camera initialization by calling getSupportedSize() first to populate native size data, and querying with type=-1 to include all frame formats
  • Add missing CAMERA permission to example app AndroidManifest.xml so permission_handler can request runtime camera permission
  • Add guard against empty supported size list with a clear error message instead of IndexOutOfBoundsException

Root Cause

  • camera.getSupportedSizeList() relies on mSupportedSize being populated from native via getSupportedSize(), which was never called before
  • Even after populating, the method filters by mCurrentFrameFormat which isn't set yet at that point, causing YUYV-only cameras (type:4) to be excluded
  • The example app was missing <uses-permission android:name="android.permission.CAMERA" />, so the permission request silently failed

Test plan

  • Tested on Samsung Galaxy A24 (SM-A245N) with a YUYV-only UVC camera
  • Camera preview renders correctly after fix
  • Camera permission dialog appears and works

🤖 Generated with Claude Code

suhwanhwang and others added 2 commits March 19, 2026 07:22
getSupportedSizeList() returned an empty list because mSupportedSize was
not populated from native before the call, and the frame format filter
excluded valid sizes. Use getSupportedSize() to populate the native size
data first, then query with type=-1 to retrieve all supported sizes
regardless of frame format. Also add CAMERA permission to the example
app AndroidManifest and guard against empty size lists with a clear
error message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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