Android: record at real screen resolution#140
Conversation
…te other transitive dependencies.
…for higher recording quality on Android.
|
Worried about impact? Review this PR in Change Stack to explore blast radius before you approve or request changes. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR refactors the Android screen recording plugin to improve display metrics collection and introduce dynamic bitrate computation. The plugin now obtains display dimensions via the activity's window manager, calculates resolution using physical pixels with even-number rounding, and computes encoder bitrate dynamically based on total pixel count instead of using fixed values. ChangesAndroid screen recording encoder optimization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
flutter_screen_recording/android/src/main/kotlin/com/isvisoft/flutter_screen_recording/FlutterScreenRecordingPlugin.kt (1)
160-166: 💤 Low valueRemove dead commented code.
The commented-out code at lines 160-162 is no longer needed and should be deleted to keep the codebase clean.
♻️ Suggested cleanup
} else { -// `@SuppressLint`("NewApi") -// val defaultDisplay = appContext.display -// defaultDisplay?.getMetrics(metrics) `@Suppress`("DEPRECATION") val defaultDisplay = activityBinding!!.activity.windowManager.defaultDisplay `@Suppress`("DEPRECATION") defaultDisplay?.getRealMetrics(metrics) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@flutter_screen_recording/android/src/main/kotlin/com/isvisoft/flutter_screen_recording/FlutterScreenRecordingPlugin.kt` around lines 160 - 166, Remove the dead commented-out block that references appContext.display and getMetrics (the commented `@SuppressLint`("NewApi") lines) in FlutterScreenRecordingPlugin.kt; keep the working code that uses activityBinding!!.activity.windowManager.defaultDisplay and defaultDisplay?.getRealMetrics(metrics) (variables: appContext, activityBinding, defaultDisplay, metrics) so the file contains no obsolete commented code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@flutter_screen_recording/android/src/main/kotlin/com/isvisoft/flutter_screen_recording/FlutterScreenRecordingPlugin.kt`:
- Around line 160-166: Remove the dead commented-out block that references
appContext.display and getMetrics (the commented `@SuppressLint`("NewApi") lines)
in FlutterScreenRecordingPlugin.kt; keep the working code that uses
activityBinding!!.activity.windowManager.defaultDisplay and
defaultDisplay?.getRealMetrics(metrics) (variables: appContext, activityBinding,
defaultDisplay, metrics) so the file contains no obsolete commented code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d8a7fd27-b0a4-4c20-af65-046dbe104d38
⛔ Files ignored due to path filters (1)
flutter_screen_recording/pubspec.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
flutter_screen_recording/android/src/main/kotlin/com/isvisoft/flutter_screen_recording/FlutterScreenRecordingPlugin.ktflutter_screen_recording/pubspec.yaml
This PR updates Android screen recording to use the device’s real physical display resolution instead of downscaling to a fixed maximum size. The recording size is now calculated dynamically from the display metrics, with even-number rounding for encoder compatibility.
It also updates the bitrate based on pixel count and ensures the same width/height are used for both
MediaRecorderandVirtualDisplay, avoiding scaling or cropping mismatches. Tested on Samsung Galaxy S24 / Android 16 with and without microphone audio.Also updated some dependencies.
Summary by CodeRabbit
Improvements
Chores