Skip to content

High performance self-hosted photo and video management solution.

fix(mobile): video player using ref after disposal (#21843)

Mert43b06a036da4
diff --git a/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart b/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart
index fa7f204596..3040af590e 100644
--- a/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart
+++ b/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart
@@ -88,10 +88,18 @@ class NativeVideoViewer extends HookConsumerWidget {
}
final videoAsset = await ref.read(assetServiceProvider).getAsset(asset) ?? asset;
+ if (!context.mounted) {
+ return null;
+ }
+
try {
if (videoAsset.hasLocal && videoAsset.livePhotoVideoId == null) {
final id = videoAsset is LocalAsset ? videoAsset.id : (videoAsset as RemoteAsset).localId!;
final file = await const StorageRepository().getFileForAsset(id);
+ if (!context.mounted) {
+ return null;
+ }
+
if (file == null) {
throw Exception('No file found for the video');
}
@@ -289,7 +297,7 @@ class NativeVideoViewer extends HookConsumerWidget {
ref.read(videoPlaybackValueProvider.notifier).reset();
final source = await videoSource;
- if (source == null) {
+ if (source == null || !context.mounted) {
return;
}