Skip to content

feat: pick Android emulator camera source; fix laggy headless streams - #75

Merged
dungngminh merged 3 commits into
mainfrom
feat/android-emulator-camera
Oct 21, 2026
Merged

dungngminh merged 3 commits into
mainfrom
feat/android-emulator-camera

Conversation

@dungngminh

@dungngminh dungngminh commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Description

Android emulator camera source (CLI, TUI, desktop app, MCP)

  • Pick what an emulator's back and front cameras see: a host webcam (webcam<N>), an image, a video file, virtualscene, emulated or none.
  • CLI: simutil launch --camera-back / --camera-front. Desktop app: device menu → Camera (used from the next boot), or the new camera button on a running emulator's stream tile (restarts it). MCP: start_device takes cameraBack / cameraFront.
  • macOS: SimUtil asks for Camera access before booting with a webcam; when denied, the emulator starts with its own cameras instead of hanging.
  • One webcam cannot feed both cameras (the emulator's camera app crashes).
  • simutil_adb: emulatorCameraArgs, AndroidDeviceService.listWebcams().

Headless emulator stream fixes

  • Headless emulators (-no-window) fell back to software rendering (lavapipe) under -gpu auto, so the scrcpy stream ran at ~5 fps. They now launch with -gpu host unless the caller passes its own -gpu.
    • Measured on a Pixel 7 Pro AVD (1440x3120), scrolling continuously, app stream settings (1280, 8 Mbps, 60 fps): 5.1 → 54.4 fps, max frame gap 1077 → 230 ms. In the desktop app: 49–60 fps.
  • Streaming an emulator right as it starts failed with scrcpy server did not start ... NullPointerException ... ActivityManager.getContentProviderExternal: adb lists an emulator before Android finishes booting. ScrcpySession now waits for sys.boot_completed (up to 3 min) before starting the server.

Not tested: -gpu host on Linux / Windows hosts without a usable GPU (VMs, RDP); passing -gpu swiftshader_indirect overrides it.

Type of Change

  • 🔥 New feature (non-breaking change which adds functionality)
  • ✨ Enhancement (non-breaking change which improves existing functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • 🧹 Code refactor
  • 📝 Documentation
  • 🗑️ Chore
  • 📦 Build configuration change
  • ✅ Test

Summary by CodeRabbit

  • New Features
    • Configure Android emulator back and front cameras using webcams, images, videos, virtual scenes, or disabled input.
    • Select camera sources from device menus, live streams, or launch commands.
    • Request camera permission when using a Mac webcam.
    • Discover connected webcams automatically.
  • Bug Fixes
    • Headless Android streaming now uses the computer’s GPU for improved playback speed.
    • Streaming waits for Android startup to complete before connecting.
  • Documentation
    • Added launch-option guidance and examples for camera configuration.

Emulator -camera-back/-camera-front from the app's device menu
(Camera, next boot), CLI --camera-back/--camera-front, and MCP
start_device cameraBack/cameraFront. simutil_adb 1.4.0 adds
emulatorCameraArgs and AndroidDeviceService.listWebcams.
Add a camera button on a running Android emulator's stream tile that
picks the back/front source and restarts the emulator. Ask for macOS
Camera access before booting with a host webcam (falls back to the
emulator's own cameras when denied), and reject one webcam feeding both
cameras, which crashes the emulator's camera app.
Headless emulators (-no-window) fall back to software rendering
(lavapipe) under `-gpu auto`, so scrcpy streamed at ~5 fps. Launch them
with `-gpu host` unless the caller passes its own `-gpu`: ~55 fps.

adb lists an emulator before Android finishes booting, so a stream
opened at boot started scrcpy-server too early and it crashed with a
null ActivityManager. ScrcpySession now waits for sys.boot_completed
(up to 3 min) before starting the server.
@dungngminh dungngminh added the feature Features ✨ label Oct 21, 2026
@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bdcbf6de-82dd-4843-a04f-e8b48dce9ec3
📥 Commits

Reviewing files that changed from the base of the PR and between 67bfd1f and 5f61081.

📒 Files selected for processing: 25
  • app/CHANGELOG.md
  • app/lib/src/devices/devices_cubit.dart
  • app/lib/src/mcp/tools/device_tools.dart
  • app/lib/src/settings/device_settings_cubit.dart
  • app/lib/src/ui/shared/device_actions.dart
  • app/lib/src/ui/shared/device_context_menu.dart
  • app/lib/src/ui/streams/stream_tile.dart
  • app/macos/Runner/DeviceStream.swift
  • app/pubspec.yaml
  • app/test/desktop_settings_store_test.dart
  • packages/simutil/CHANGELOG.md
  • packages/simutil/lib/src/cli/cli_catalog.dart
  • packages/simutil/lib/src/cli/cli_device_services.dart
  • packages/simutil/lib/src/cli/commands/launch_command.dart
  • packages/simutil/pubspec.yaml
  • packages/simutil/test/cli/cli_device_services_test.dart
  • packages/simutil_adb/CHANGELOG.md
  • packages/simutil_adb/lib/simutil_adb.dart
  • packages/simutil_adb/lib/src/android_device_service.dart
  • packages/simutil_adb/lib/src/models/emulator_camera.dart
  • packages/simutil_adb/lib/src/scrcpy/scrcpy_session.dart
  • packages/simutil_adb/pubspec.yaml
  • packages/simutil_adb/test/models/emulator_camera_test.dart
  • packages/simutil_adb/test/scrcpy/scrcpy_session_test.dart
  • packages/simutil_adb/test/services/android_device_service_test.dart
+----------------------------------------------------------------------------------------------------+
| Don't live with broken windows. Fix bad designs, wrong decisions, and poor code when you see them. |
+----------------------------------------------------------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@dungngminh
dungngminh merged commit 444037f into main Oct 21, 2026
5 of 7 checks passed
@dungngminh
dungngminh deleted the feat/android-emulator-camera branch October 21, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Features ✨

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant