fix(mobile): prevent SurfaceLayer crashing on maps in Viewer on Android (#31709)

This commit is contained in:
Adam Gastineau
2026-09-22 20:55:22 +05:30
committed by GitHub
parent 0fa1399305
commit f367ab2121
2 changed files with 10 additions and 1 deletions
+7
View File
@@ -46,10 +46,17 @@ import 'package:immich_mobile/wm_executor.dart';
import 'package:immich_ui/immich_ui.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:logging/logging.dart';
import 'package:maplibre_gl/maplibre_gl.dart';
import 'package:timezone/data/latest.dart';
void main() async {
try {
// https://github.com/flutter/flutter/issues/118384
// Android only: Render maps into a TextureView
// By default, MapLibre will embed them into platform views, using Virtual Display. For some reason Flutter has a bug
// that leaks a presentation window and SurfaceFlinger layer for every map built, and it is never discarded
MapLibreMap.useHybridComposition = true;
ImmichWidgetsBinding();
unawaited(BackgroundWorkerLockService(BackgroundWorkerLockApi()).lock());
await EasyLocalization.ensureInitialized();
@@ -514,7 +514,9 @@ class _AssetPageState extends ConsumerState<AssetPage> {
child: AnimatedOpacity(
opacity: _showingDetails ? 1.0 : 0.0,
duration: Durations.short2,
child: AssetDetails(asset: displayAsset, minHeight: viewportHeight - snapTarget),
child: _showingDetails
? AssetDetails(asset: displayAsset, minHeight: viewportHeight - snapTarget)
: SizedBox(height: viewportHeight - snapTarget),
),
),
],