Flutter app renders black screen on foldable Android phones after fold/unfold events — display density and PlatformView mismatch
Environment
Flutter 3.3 app compiled in release mode, target device: Android foldable (Android 12L), app uses a mix of Flutter widgets and an embedded PlatformView for a native video player. Reproducible on Samsung Galaxy Z Fold 3 and in Foldable emulator configuration in Android Studio.
Symptoms
User launches app on folded device: UI renders normally. On unfolding the device, the app surface goes completely black (no UI), audio continues if video was playing. Closing and reopening the app sometimes restores UI; rotating device does not help. The black screen typically appears only when a PlatformView was visible during the fold/unfold transition.
Observations
ADB logcat shows SurfaceControl errors and messages about 'Windowless surface destroyed' and 'composite failed' around the time of folding. Flutter engine logs indicate a GPU surface reconfiguration attempt and a mismatch between physical display metrics and Flutter's rasterizer surface size. Reproduces only in release builds; debug builds with observatory remain stable (but have different timing). Using a pure Flutter video player (no PlatformView) reduced frequency but did not eliminate the problem. The device reports a configuration change with a new displayRect and density when unfolded.
Already attempted
Updated flutter channel to latest stable, added handling for WidgetsBindingObserver didChangeMetrics to force rebuild on metrics change, attempted to recreate PlatformView onActivityRecreate — no consistent fix. Tested toggling Android:hardwareAccelerated and different Flutter embeddings (v2) without luck. Reproduced in emulator fold events and on hardware.
Question
What causes a black Flutter surface after fold/unfold transitions on Android foldable devices, especially when PlatformView is present, and what reversible application or embedding-level strategies can be used to force a safe surface reattachment without losing user state? When should this be escalated to Flutter engine or OEM bug trackers?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags