Repository navigation
feat(app): stream Android emulators over the emulator's gRPC API - #77
Merged
Merged
Conversation
Emulators on macOS now stream like Android Studio's embedded emulator: EmulatorController.streamScreenshot with the MMAP transport writes raw RGB888 frames into a file the new SharedFrameTexture (simutil_h264) maps and converts to a BGRA texture, sized to the view and re-requested on resize/rotation. Input goes through streamInputEvent (touch with rotation undone, W3C keys, text); recording uses adb emu screenrecord and ffmpeg. The endpoint comes from the emulator's discovery file (avd/running/pid_<pid>.ini, matched by port.serial). Emulators without gRPC, physical devices and Linux/Windows keep scrcpy. Measured on a Pixel 7 Pro AVD (-gpu host) while scrolling: 60.0 fps steady vs 51-59 fps with scrcpy, emulator CPU ~10% vs ~15%. Stubs are generated from a trimmed copy of emulator_controller.proto (melos run protoc).
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters: 4
📒 Files selected for processing: 27
✨ Finishing Touches
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Android emulators on macOS now stream the way Android Studio's embedded emulator does: through the emulator's own gRPC API instead of scrcpy, so the guest never encodes H.264.
EmulatorGrpcSession(simutil_adb): finds the endpoint from the emulator's discovery file (~/Library/Caches/TemporaryItems/avd/running/pid_<pid>.ini, matched byport.serial; token sent asauthorization: Bearer, never logged). Video isstreamScreenshotwith RGB888 and the MMAP transport into a file the view owns; input isstreamInputEvent(touch with rotation undone, W3C keysGoBack/GoHome/AppSwitch…, text viaKeyboardEvent.text). Recording usesadb emu screenrecord(webm) converted to mp4 with ffmpeg.SharedFrameTexture(simutil_h2640.2.0, macOS): maps the shared file and converts each frame (vImage RGB888 → BGRA) into a pooledCVPixelBuffertexture.EmulatorVideoViewrequests the view's physical pixel size (capped at the display), re-requesting on resize/rotation. Falls back toScrcpySessionwhen no gRPC endpoint shows up (old emulators,-no-grpc); physical devices and Linux/Windows keep scrcpy.emulator_controller.proto, checked in;melos run protocregenerates them.Measured on a Pixel 7 Pro AVD (1440x3120,
-gpu host) while scrolling continuously, profile build, same load:Verified: tap / swipe / back / typing / Backspace, all four rotations (pointer_location), recording to H.264 mp4.
Known: stream device settings (max fps, bit rate, show touches, stay awake, screen off) don't apply to gRPC emulator streams. Emulator 37.2.12 aborted once inside its gRPC server around a force-kill of the app mid-stream; not reproducible in 5+ tries.
Type of Change