Skip to content

fix(adb): wait for the first emulator frame instead of failing - #91

Open
KrohnMi wants to merge 2 commits into
dungngminh:mainfrom
KrohnMi:fix/emulator-grpc-boot-frames
Open

KrohnMi wants to merge 2 commits into
dungngminh:mainfrom
KrohnMi:fix/emulator-grpc-boot-frames

Conversation

@KrohnMi

@KrohnMi KrohnMi commented Nov 9, 2026 •

Copy link
Copy Markdown

Description

Streaming an Android emulator right after starting it from the desktop app fails with:

gRPC: The guest has not posted new frames

Cause. The app opens the stream as soon as adb lists the emulator, which happens before Android draws its first frame. EmulatorGrpcSession._readDisplay already waits up to 3 min for the display, but only while getScreenshot returns an empty (0×0) image. Until the first frame, the emulator instead answers with the gRPC error above, so start() failed at once.

Fix. _readDisplay treats gRPC errors like an empty display: it asks again every 500 ms until the existing 3 min boot timeout, then reports the last error. Errors that waiting cannot fix still fail right away: unauthenticated (wrong token), permissionDenied, unimplemented and invalidArgument.

simutil_adb goes to 1.4.1 (fix only, no API change). The app changelog is updated.

Verified

  • New test/emulator/emulator_grpc_session_test.dart runs a local gRPC server as the emulator:
    • it answers unavailable: The guest has not posted new frames twice, then a 0×0 image, then the display → the session goes live at 1080×2424. Against main this fails with SessionFailed, the reported symptom;
    • unauthenticated → SessionFailed('gRPC: bad token') after a single call.
  • dart analyze --fatal-infos, format check and melos run test are green; in app, flutter analyze is clean and flutter test passes 117.
  • Against an already booted emulator (API 37, -no-window -gpu host, also with the screen off), the session still goes live in about 1 s.
  • Not verified end to end: reproducing the boot-time error against a real emulator. The test covers that path.

simutil_adb is also bumped in #81 (1.5.0) and #86 (1.4.1); whichever merges later needs a trivial version/changelog merge.

Suggested labels: fixbug, app, macos.

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

  • Bug Fixes
    • Emulator streaming now waits for the first usable frame during startup instead of failing immediately. Startup-related display errors are retried for up to three minutes, while authentication and other non-retryable errors still fail immediately.

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2c7e3300-5eca-4cac-b622-c043d3aef060
Commits

Reviewing files that changed from the base of the PR and between c7de7a3 and 32792c4.

Files selected for processing: 5

  • app/CHANGELOG.md
  • packages/simutil_adb/CHANGELOG.md
  • packages/simutil_adb/lib/src/emulator/emulator_grpc_session.dart
  • packages/simutil_adb/pubspec.yaml
  • packages/simutil_adb/test/emulator/emulator_grpc_session_test.dart

No actionable comments were generated in the recent review.

Walkthrough

The emulator gRPC session now retries eligible screenshot errors during startup until the boot deadline. It still fails immediately for unauthenticated, permission-denied, unimplemented, and invalid-argument errors. Tests cover retry behavior and immediate authentication failure. The package version is now 1.4.1.

Changes: Emulator display startup

Layer / File(s) Summary
Retry display polling
packages/simutil_adb/lib/src/emulator/emulator_grpc_session.dart, packages/simutil_adb/test/emulator/emulator_grpc_session_test.dart, app/CHANGELOG.md, packages/simutil_adb/CHANGELOG.md, packages/simutil_adb/pubspec.yaml
_readDisplay retries eligible gRPC errors every 500 ms until the boot deadline and throws the last retryable error on timeout. Tests verify retrying UNAVAILABLE, skipping a zero-sized image, reaching a live session, and failing immediately on UNAUTHENTICATED. The changelogs describe the behavior, and the package version changes to 1.4.1.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: dungngminh

Merge Risk: Minimal · previous review c7de7

No actionable issue remains in the supplied review evidence; the change is mergeable after normal checks.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(adb): wait for the first emulator frame instead of failing" names the main change. The PR makes _readDisplay retry screenshot gRPC errors every 500 ms within the three-minute boot dea…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Title check

Explanation

The title "fix(adb): wait for the first emulator frame instead of failing" names the main change. The PR makes _readDisplay retry screenshot gRPC errors every 500 ms within the three-minute boot deadline, so streaming waits for the first emulator frame rather than failing immediately. The title is specific, concise, and uses a conventional-commit scope that matches the simutil_adb package. The objectives and changelog entries confirm the same primary change.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (5 skipped: 5 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • 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

A rabbit waits while boot screens glow,
And counts each frame that starts to show.
The errors pass; the pixels stream,
A steady screen completes the scene.
Then off I hop, content as can be.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83f7ee0f-e6ea-40f0-96ef-8af732f33ec7
Commits

Reviewing files that changed from the base of the PR and between 1965409 and c7de7a3.

Files selected for processing: 5

  • app/CHANGELOG.md
  • packages/simutil_adb/CHANGELOG.md
  • packages/simutil_adb/lib/src/emulator/emulator_grpc_session.dart
  • packages/simutil_adb/pubspec.yaml
  • packages/simutil_adb/test/emulator/emulator_grpc_session_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

@kilo-code-bot

kilo-code-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • app/CHANGELOG.md
  • app/pubspec.yaml
Previous Review Summary (commit c7de7a3)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c7de7a3)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • app/CHANGELOG.md
  • packages/simutil_adb/CHANGELOG.md
  • packages/simutil_adb/lib/src/emulator/emulator_grpc_session.dart
  • packages/simutil_adb/pubspec.yaml
  • packages/simutil_adb/test/emulator/emulator_grpc_session_test.dart

Reviewed by free · Input: 18.8K · Output: 604 · Cached: 73.2K

@KrohnMi
KrohnMi force-pushed the fix/emulator-grpc-boot-frames branch from c7de7a3 to 32792c4 Compare November 11, 2026 08:20
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