diff --git a/lib/services/metadata/metadata_edit_service.dart b/lib/services/metadata/metadata_edit_service.dart index aeb8aec66..8b7fa8c28 100644 --- a/lib/services/metadata/metadata_edit_service.dart +++ b/lib/services/metadata/metadata_edit_service.dart @@ -36,9 +36,7 @@ class PlatformMetadataEditService implements MetadataEditService { }); if (result != null) return (result as Map).cast(); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { - await reportService.recordError(e, stack); - } + await _processPlatformException(entry, e, stack); } return {}; } @@ -52,9 +50,7 @@ class PlatformMetadataEditService implements MetadataEditService { }); if (result != null) return (result as Map).cast(); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { - await reportService.recordError(e, stack); - } + await _processPlatformException(entry, e, stack); } return {}; } @@ -70,9 +66,7 @@ class PlatformMetadataEditService implements MetadataEditService { }); if (result != null) return (result as Map).cast(); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { - await reportService.recordError(e, stack); - } + await _processPlatformException(entry, e, stack); } return {}; } @@ -91,9 +85,7 @@ class PlatformMetadataEditService implements MetadataEditService { }); if (result != null) return (result as Map).cast(); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { - await reportService.recordError(e, stack); - } + await _processPlatformException(entry, e, stack); } return {}; } @@ -106,9 +98,7 @@ class PlatformMetadataEditService implements MetadataEditService { }); if (result != null) return (result as Map).cast(); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { - await reportService.recordError(e, stack); - } + await _processPlatformException(entry, e, stack); } return {}; } @@ -122,10 +112,52 @@ class PlatformMetadataEditService implements MetadataEditService { }); if (result != null) return (result as Map).cast(); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { - await reportService.recordError(e, stack); - } + await _processPlatformException(entry, e, stack); } return {}; } + + Future _processPlatformException(AvesEntry entry, PlatformException e, StackTrace stack) async { + if (!entry.isMissingAtPath) { + final code = e.code; + if (code.endsWith('mp4largemoov')) { + await reportService.recordError(_Mp4LargeMoovException(code: e.code, message: e.message, details: e.details, stacktrace: e.stacktrace), stack); + } else if (code.endsWith('mp4largeother')) { + await reportService.recordError(_Mp4LargeOtherException(code: e.code, message: e.message, details: e.details, stacktrace: e.stacktrace), stack); + } else if (code.endsWith('filenotfound')) { + await reportService.recordError(_FileNotFoundException(code: e.code, message: e.message, details: e.details, stacktrace: e.stacktrace), stack); + } else { + await reportService.recordError(e, stack); + } + } + } +} + +// distinct exceptions to convince Crashlytics to split reports into distinct issues + +class _Mp4LargeMoovException extends PlatformException { + _Mp4LargeMoovException({ + required super.code, + required super.message, + required super.details, + required super.stacktrace, + }); +} + +class _Mp4LargeOtherException extends PlatformException { + _Mp4LargeOtherException({ + required super.code, + required super.message, + required super.details, + required super.stacktrace, + }); +} + +class _FileNotFoundException extends PlatformException { + _FileNotFoundException({ + required super.code, + required super.message, + required super.details, + required super.stacktrace, + }); } diff --git a/lib/widgets/viewer/visual/entry_page_view.dart b/lib/widgets/viewer/visual/entry_page_view.dart index 2257879b9..32e1c8f2a 100644 --- a/lib/widgets/viewer/visual/entry_page_view.dart +++ b/lib/widgets/viewer/visual/entry_page_view.dart @@ -336,10 +336,13 @@ class _EntryPageViewState extends State with SingleTickerProvider ], ); if (useVerticalDragGesture) { - videoChild = MagnifierGestureDetectorScope.of(context)!.copyWith( - acceptPointerEvent: MagnifierGestureRecognizer.isYPan, - child: videoChild, - ); + final scope = MagnifierGestureDetectorScope.maybeOf(context); + if (scope != null) { + videoChild = scope.copyWith( + acceptPointerEvent: MagnifierGestureRecognizer.isYPan, + child: videoChild, + ); + } } return Stack( fit: StackFit.expand, diff --git a/plugins/aves_magnifier/lib/src/core/gesture_detector.dart b/plugins/aves_magnifier/lib/src/core/gesture_detector.dart index e9ae6017b..76a6e1348 100644 --- a/plugins/aves_magnifier/lib/src/core/gesture_detector.dart +++ b/plugins/aves_magnifier/lib/src/core/gesture_detector.dart @@ -54,7 +54,7 @@ class _MagnifierGestureDetectorState extends State { ); } - final scope = MagnifierGestureDetectorScope.of(context); + final scope = MagnifierGestureDetectorScope.maybeOf(context); if (scope != null) { gestures[MagnifierGestureRecognizer] = GestureRecognizerFactoryWithHandlers( () => MagnifierGestureRecognizer( diff --git a/plugins/aves_magnifier/lib/src/pan/gesture_detector_scope.dart b/plugins/aves_magnifier/lib/src/pan/gesture_detector_scope.dart index a9b52c9fe..82da68aea 100644 --- a/plugins/aves_magnifier/lib/src/pan/gesture_detector_scope.dart +++ b/plugins/aves_magnifier/lib/src/pan/gesture_detector_scope.dart @@ -24,7 +24,7 @@ class MagnifierGestureDetectorScope extends InheritedWidget { required Widget child, }) : super(child: child); - static MagnifierGestureDetectorScope? of(BuildContext context) { + static MagnifierGestureDetectorScope? maybeOf(BuildContext context) { return context.dependOnInheritedWidgetOfExactType(); }