Skip to content

High performance self-hosted photo and video management solution.

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

Adam Gastineauf367ab2121f3
diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart
index cc868de294..21189783b6 100644
--- a/mobile/lib/main.dart
+++ b/mobile/lib/main.dart
@@ -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();
diff --git a/mobile/lib/presentation/widgets/asset_viewer/asset_page.widget.dart b/mobile/lib/presentation/widgets/asset_viewer/asset_page.widget.dart
index c1ba71cfa9..663360ef61 100644
--- a/mobile/lib/presentation/widgets/asset_viewer/asset_page.widget.dart
+++ b/mobile/lib/presentation/widgets/asset_viewer/asset_page.widget.dart
@@ -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),
),
),
],