π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Prevent filmstrip photo handoff flicker
ashil-pilot0b43debe3287
diff --git a/mobile/apps/photos/changes/gallery-filmstrip-photo-flicker.md b/mobile/apps/photos/changes/gallery-filmstrip-photo-flicker.mdnew file mode 100644index 0000000000..ec76276b10--- /dev/null+++ b/mobile/apps/photos/changes/gallery-filmstrip-photo-flicker.md@@ -0,0 +1 @@+- Fixed a loading flicker when opening photos from the gallery viewer filmstrip.diff --git a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dartindex 2e09c4eac3..84a006f30c 100644--- a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart@@ -37,6 +37,7 @@ import "package:photos/ui/tools/editor/video_editor_page.dart";import "package:photos/ui/viewer/file/file_app_bar.dart";import "package:photos/ui/viewer/file/file_bottom_bar.dart";import "package:photos/ui/viewer/file/file_viewer_filmstrip_coordinator.dart";+import "package:photos/ui/viewer/file/file_viewer_image_page_readiness.dart";import 'package:photos/ui/viewer/file/file_widget.dart';import "package:photos/ui/viewer/file/gallery_file_viewer_filmstrip.dart";import "package:photos/ui/viewer/file/ocr/inline_text_detection.dart";@@ -187,6 +188,8 @@ class _BodyState extends State<_Body> {late PageController _pageController;final _selectedIndexNotifier = ValueNotifier(0);late final FileViewerFilmstripCoordinator _filmstripCoordinator;+ late final FileViewerImagePageReadinessRegistration+ _imagePageReadinessRegistration;final _inlineTextDetectionController = InlineTextDetectionController();bool _isFirstOpened = true;bool isGuestView = false;@@ -228,7 +231,12 @@ class _BodyState extends State<_Body> {Bus.instance.fire(PauseVideoEvent(fileTag: selectedFile!.tag));}},+ waitsForImageFrame: (identity) =>+ identity is EnteFile &&+ (identity.fileType == FileType.image ||+ identity.fileType == FileType.livePhoto),);+ _imagePageReadinessRegistration = _registerImagePageReadiness;_guestViewEventSubscription = Bus.instance.on<GuestViewEvent>().listen((event,) {@@ -589,6 +597,9 @@ class _BodyState extends State<_Body> {_evaluateQrIfEligible(file);}},+ onImagePageReadinessRegistration: _shouldShowFilmstrip+ ? _imagePageReadinessRegistration+ : null,qrDetectionsNotifier: _qrHelper?.qrDetectionsNotifier,playbackSpeed: _playbackSpeed,streamChangeController: _videoStreamChangeControllerFor(file),@@ -650,6 +661,18 @@ class _BodyState extends State<_Body> {);}+ void _registerImagePageReadiness(+ Object fileIdentity,+ ValueListenable<bool> readiness, {+ required bool isAttached,+ }) {+ if (isAttached) {+ _filmstripCoordinator.attachImagePage(fileIdentity, readiness);+ } else {+ _filmstripCoordinator.detachImagePage(fileIdentity, readiness);+ }+ }+void _evaluateQrIfEligible(EnteFile file) {_qrHelper?.evaluateFile(file,diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_viewer_filmstrip_coordinator.dart b/mobile/apps/photos/lib/ui/viewer/file/file_viewer_filmstrip_coordinator.dartindex 9d7cae43a1..75a792173d 100644--- a/mobile/apps/photos/lib/ui/viewer/file/file_viewer_filmstrip_coordinator.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/file_viewer_filmstrip_coordinator.dart@@ -8,6 +8,8 @@ typedef FileViewerFilmstripIdentityAt = Object? Function(int index);typedef FileViewerFilmstripImmediatePageJump = bool Function(int index);+typedef FileViewerFilmstripWaitsForImageFrame = bool Function(Object identity);+// Runs [callback] after a guaranteed future frame's paint phase.typedef FileViewerFilmstripPaintScheduler =void Function(VoidCallback callback);@@ -23,8 +25,10 @@ class FileViewerFilmstripCoordinator {final FileViewerFilmstripImmediatePageJump _jumpToPageImmediately;final VoidCallback _requestPauseCurrentMedia;final FileViewerFilmstripPaintScheduler _scheduleAfterNextFramePaint;+ final FileViewerFilmstripWaitsForImageFrame _waitsForImageFrame;final ValueNotifier<int?> _previewIndexNotifier = ValueNotifier(null);+ final Map<Object, _ActiveImagePage> _activeImagePages = Map.identity();_FilmstripSession _session = const _IdleFilmstripSession();bool _isDisposed = false;@@ -34,11 +38,13 @@ class FileViewerFilmstripCoordinator {required FileViewerFilmstripIdentityAt identityAt,required FileViewerFilmstripImmediatePageJump jumpToPageImmediately,required VoidCallback requestPauseCurrentMedia,+ FileViewerFilmstripWaitsForImageFrame? waitsForImageFrame,FileViewerFilmstripPaintScheduler? scheduleAfterNextFramePaint,}) : _currentIndex = currentIndex,_identityAt = identityAt,_jumpToPageImmediately = jumpToPageImmediately,_requestPauseCurrentMedia = requestPauseCurrentMedia,+ _waitsForImageFrame = waitsForImageFrame ?? ((_) => false),_scheduleAfterNextFramePaint =scheduleAfterNextFramePaint ?? _afterNextFramePaint;@@ -92,22 +98,93 @@ class FileViewerFilmstripCoordinator {void handlePageChanged(int index, Object fileIdentity) {if (_isDisposed) return;final pendingSession = _session;- if (pendingSession is! _AwaitingPagePaintFilmstripSession ||- pendingSession.hasScheduledPaintBarrier ||- !_matchesAwaitingSession(pendingSession, index, fileIdentity)) {+ if (pendingSession is! _PendingFilmstripHandoffSession ||+ pendingSession.previewRemovalScheduled ||+ !_matchesPendingHandoff(pendingSession, index, fileIdentity)) {return;}- final session = _AwaitingPagePaintFilmstripSession(- index,- fileIdentity,- hasScheduledPaintBarrier: true,+ final session = pendingSession.copyWith(destinationPageSelected: true);+ _setSession(session);+ _schedulePreviewRemovalIfReady(session);+ }++ void attachImagePage(Object fileIdentity, ValueListenable<bool> readiness) {+ if (_isDisposed) return;+ final currentPage = _activeImagePages[fileIdentity];+ if (currentPage != null) {+ if (identical(currentPage.readiness, readiness)) return;+ currentPage.readiness.removeListener(currentPage.listener);+ }++ void listener() =>+ _handleImagePageReadinessChanged(fileIdentity, readiness);++ _activeImagePages[fileIdentity] = (+ readiness: readiness,+ listener: listener,);+ readiness.addListener(listener);+ _handleImagePageReadinessChanged(fileIdentity, readiness);+ }++ void detachImagePage(Object fileIdentity, ValueListenable<bool> readiness) {+ if (_isDisposed) return;+ final currentPage = _activeImagePages[fileIdentity];+ if (currentPage == null || !identical(currentPage.readiness, readiness)) {+ return;+ }+ readiness.removeListener(currentPage.listener);+ _activeImagePages.remove(fileIdentity);+ _invalidateScheduledRemovalFor(fileIdentity);+ }++ void _handleImagePageReadinessChanged(+ Object fileIdentity,+ ValueListenable<bool> readiness,+ ) {+ final currentPage = _activeImagePages[fileIdentity];+ if (currentPage == null || !identical(currentPage.readiness, readiness)) {+ return;+ }+ if (!readiness.value) {+ _invalidateScheduledRemovalFor(fileIdentity);+ return;+ }+ final session = _session;+ if (session is _PendingFilmstripHandoffSession &&+ identical(session.identity, fileIdentity)) {+ _schedulePreviewRemovalIfReady(session);+ }+ }++ void _invalidateScheduledRemovalFor(Object fileIdentity) {+ final session = _session;+ if (session is! _PendingFilmstripHandoffSession ||+ !session.previewRemovalScheduled ||+ !identical(session.identity, fileIdentity)) {+ return;+ }+ _setSession(session.copyWith(previewRemovalScheduled: false));+ }++ void _schedulePreviewRemovalIfReady(+ _PendingFilmstripHandoffSession pendingSession,+ ) {+ if (pendingSession.previewRemovalScheduled ||+ !pendingSession.destinationPageSelected) {+ return;+ }+ if (_waitsForImageFrame(pendingSession.identity)) {+ final imagePage = _activeImagePages[pendingSession.identity];+ if (imagePage == null || !imagePage.readiness.value) return;+ }+ final session = pendingSession.copyWith(previewRemovalScheduled: true);_setSession(session);_scheduleAfterNextFramePaint(() {if (_isDisposed ||!identical(_session, session) ||- _currentIndex() != index ||- !identical(_identityAt(index), fileIdentity)) {+ _currentIndex() != session.index ||+ !identical(_identityAt(session.index), session.identity)) {return;}reset();@@ -122,14 +199,14 @@ class FileViewerFilmstripCoordinator {void _commit(int index, Object targetIdentity) {if (index == _currentIndex()) {final session = _session;- if (session is! _AwaitingPagePaintFilmstripSession ||- !_matchesAwaitingSession(session, index, targetIdentity)) {+ if (session is! _PendingFilmstripHandoffSession ||+ !_matchesPendingHandoff(session, index, targetIdentity)) {reset();}return;}- final session = _AwaitingPagePaintFilmstripSession(index, targetIdentity);+ final session = _PendingFilmstripHandoffSession(index, targetIdentity);_setSession(session);if (!identical(_session, session)) return;if (!_jumpToPageImmediately(index)) {@@ -137,8 +214,8 @@ class FileViewerFilmstripCoordinator {}}- bool _matchesAwaitingSession(- _AwaitingPagePaintFilmstripSession session,+ bool _matchesPendingHandoff(+ _PendingFilmstripHandoffSession session,int index,Object identity,) => session.index == index && identical(session.identity, identity);@@ -151,6 +228,10 @@ class FileViewerFilmstripCoordinator {void dispose() {_isDisposed = true;_session = const _IdleFilmstripSession();+ for (final page in _activeImagePages.values) {+ page.readiness.removeListener(page.listener);+ }+ _activeImagePages.clear();_previewIndexNotifier.dispose();}}@@ -179,21 +260,40 @@ final class _ScrubbingFilmstripSession extends _FilmstripSession {});}-final class _AwaitingPagePaintFilmstripSession extends _FilmstripSession {+final class _PendingFilmstripHandoffSession extends _FilmstripSession {final int index;final Object identity;- final bool hasScheduledPaintBarrier;+ final bool destinationPageSelected;+ final bool previewRemovalScheduled;@overrideint get previewIndex => index;- const _AwaitingPagePaintFilmstripSession(+ const _PendingFilmstripHandoffSession(this.index,this.identity, {- this.hasScheduledPaintBarrier = false,+ this.destinationPageSelected = false,+ this.previewRemovalScheduled = false,});++ _PendingFilmstripHandoffSession copyWith({+ bool? destinationPageSelected,+ bool? previewRemovalScheduled,+ }) => _PendingFilmstripHandoffSession(+ index,+ identity,+ destinationPageSelected:+ destinationPageSelected ?? this.destinationPageSelected,+ previewRemovalScheduled:+ previewRemovalScheduled ?? this.previewRemovalScheduled,+ );}+typedef _ActiveImagePage = ({+ ValueListenable<bool> readiness,+ VoidCallback listener,+});+void _afterNextFramePaint(VoidCallback callback) {WidgetsBinding.instance.scheduleFrameCallback((_) {WidgetsBinding.instance.addPostFrameCallback((_) => callback());diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_viewer_image_page_readiness.dart b/mobile/apps/photos/lib/ui/viewer/file/file_viewer_image_page_readiness.dartnew file mode 100644index 0000000000..01b392c123--- /dev/null+++ b/mobile/apps/photos/lib/ui/viewer/file/file_viewer_image_page_readiness.dart@@ -0,0 +1,8 @@+import "package:flutter/foundation.dart";++typedef FileViewerImagePageReadinessRegistration =+ void Function(+ Object fileIdentity,+ ValueListenable<bool> readiness, {+ required bool isAttached,+ });diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/file_widget.dartindex 767cbb5abe..a03cf4462c 100644--- a/mobile/apps/photos/lib/ui/viewer/file/file_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/file_widget.dart@@ -6,6 +6,7 @@ import 'package:logging/logging.dart';import 'package:photos/models/file/file.dart';import 'package:photos/models/file/file_type.dart';import "package:photos/states/detail_page_state.dart";+import "package:photos/ui/viewer/file/file_viewer_image_page_readiness.dart";import "package:photos/ui/viewer/file/qr_code_detection_helper.dart";import "package:photos/ui/viewer/file/video_stream_change.dart";import "package:photos/ui/viewer/file/video_widget.dart";@@ -27,6 +28,8 @@ class FileWidget extends StatelessWidget {final VideoStreamChangeController? streamChangeController;final Function({required int memoryDuration})? onFinalFileLoad;final ValueChanged<File>? onFinalImageLoaded;+ final FileViewerImagePageReadinessRegistration?+ onImagePageReadinessRegistration;final ValueNotifier<QrCodeDetectionResult?>? qrDetectionsNotifier;final GestureLongPressStartCallback? onTextSelectionStart;@@ -46,6 +49,7 @@ class FileWidget extends StatelessWidget {this.streamChangeController,this.onFinalFileLoad,this.onFinalImageLoaded,+ this.onImagePageReadinessRegistration,this.qrDetectionsNotifier,this.onTextSelectionStart,super.key,@@ -66,6 +70,7 @@ class FileWidget extends StatelessWidget {key: key ?? ValueKey(fileKey),onFinalFileLoad: onFinalFileLoad,onFinalImageLoaded: onFinalImageLoaded,+ onImagePageReadinessRegistration: onImagePageReadinessRegistration,qrDetectionsNotifier: qrDetectionsNotifier,onTextSelectionStart: onTextSelectionStart,);diff --git a/mobile/apps/photos/lib/ui/viewer/file/image_zoom/image_zoom_viewer.dart b/mobile/apps/photos/lib/ui/viewer/file/image_zoom/image_zoom_viewer.dartindex 3d11af63ae..678e5f10be 100644--- a/mobile/apps/photos/lib/ui/viewer/file/image_zoom/image_zoom_viewer.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/image_zoom/image_zoom_viewer.dart@@ -95,6 +95,7 @@ class ImageZoomViewer extends StatefulWidget {final ImageErrorWidgetBuilder? errorBuilder;final String? semanticLabel;final ValueChanged<bool>? onInteractionLockChanged;+ final VoidCallback? onImageFrameReady;final Duration animationDuration;const ImageZoomViewer({@@ -113,6 +114,7 @@ class ImageZoomViewer extends StatefulWidget {this.errorBuilder,this.semanticLabel,this.onInteractionLockChanged,+ this.onImageFrameReady,this.animationDuration = const Duration(milliseconds: 220),}) : assert(initialFit == BoxFit.contain || initialFit == BoxFit.cover),assert(maxScaleOverCover > 0);@@ -291,6 +293,7 @@ class _ImageZoomViewerState extends State<ImageZoomViewer>} else if (mounted) {setState(update);}+ widget.onImageFrameReady?.call();imageInfo.dispose();}diff --git a/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart b/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dartindex e781483b78..99a02cb51e 100644--- a/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart@@ -25,6 +25,7 @@ import "package:photos/service_locator.dart" show flagService;import "package:photos/src/rust/api/image_processing_api.dart" as rust_image;import "package:photos/states/detail_page_state.dart";import "package:photos/ui/actions/file/file_actions.dart";+import "package:photos/ui/viewer/file/file_viewer_image_page_readiness.dart";import "package:photos/ui/viewer/file/image_zoom/image_zoom_viewer.dart";import 'package:photos/ui/viewer/file/thumbnail_widget.dart';import 'package:photos/utils/dialog_util.dart';@@ -42,6 +43,8 @@ class ZoomableImage extends StatefulWidget {final bool enableVerticalSwipeActions;final Function({required int memoryDuration})? onFinalFileLoad;final ValueChanged<File>? onFinalImageLoaded;+ final FileViewerImagePageReadinessRegistration?+ onImagePageReadinessRegistration;const ZoomableImage(this.photo, {@@ -55,6 +58,7 @@ class ZoomableImage extends StatefulWidget {this.enableVerticalSwipeActions = true,this.onFinalFileLoad,this.onFinalImageLoaded,+ this.onImagePageReadinessRegistration,});@override@@ -80,6 +84,7 @@ class _ZoomableImageState extends State<ZoomableImage> {// for the original.bool _firedOnReady = false;bool _interactionLocked = false;+ final _imageFrameReady = ValueNotifier(false);final _imageZoomController = ImageZoomController();late final StreamSubscription<ResetZoomOfPhotoView> _resetZoomSubscription;late final StreamSubscription<RetryFailedImageLoadEvent>@@ -99,6 +104,11 @@ class _ZoomableImageState extends State<ZoomableImage> {void initState() {super.initState();_photo = widget.photo;+ widget.onImagePageReadinessRegistration?.call(+ _photo,+ _imageFrameReady,+ isAttached: true,+ );_logger = Logger("ZoomableImage");_logger.info('initState for ${_photo.generatedID} with tag ${_photo.tag}');// Render a cached thumbnail on first paint so prefetched files never@@ -158,6 +168,24 @@ class _ZoomableImageState extends State<ZoomableImage> {setState(() => _interactionLocked = isLocked);}+ @override+ void didUpdateWidget(covariant ZoomableImage oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.onImagePageReadinessRegistration !=+ widget.onImagePageReadinessRegistration) {+ oldWidget.onImagePageReadinessRegistration?.call(+ _photo,+ _imageFrameReady,+ isAttached: false,+ );+ widget.onImagePageReadinessRegistration?.call(+ _photo,+ _imageFrameReady,+ isAttached: true,+ );+ }+ }+void _onVerticalDragUpdate(DragUpdateDetails details) {if (_imageZoomController.isZoomed) return;if (details.delta.dy > dragSensitivity) {@@ -169,6 +197,12 @@ class _ZoomableImageState extends State<ZoomableImage> {@overridevoid dispose() {+ widget.onImagePageReadinessRegistration?.call(+ _photo,+ _imageFrameReady,+ isAttached: false,+ );+ _imageFrameReady.dispose();_imageZoomController..removeListener(_onZoomChanged)..dispose();@@ -199,6 +233,7 @@ class _ZoomableImageState extends State<ZoomableImage> {// Collage already owns its transform with an outer InteractiveViewer.gesturesEnabled: !widget.shouldCover,onInteractionLockChanged: _onInteractionLockChanged,+ onImageFrameReady: () => _imageFrameReady.value = true,loadingBuilder: (context, event) {// Match the loading state to the image's on-screen size during the// hero animation.diff --git a/mobile/apps/photos/lib/ui/viewer/file/zoomable_live_image_new.dart b/mobile/apps/photos/lib/ui/viewer/file/zoomable_live_image_new.dartindex 6edda3a00c..7a1d25a9de 100644--- a/mobile/apps/photos/lib/ui/viewer/file/zoomable_live_image_new.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/zoomable_live_image_new.dart@@ -18,6 +18,7 @@ import "package:photos/services/file_magic_service.dart";import "package:photos/src/rust/api/motion_photo_api.dart";import "package:photos/states/detail_page_state.dart";import 'package:photos/ui/notification/toast.dart';+import "package:photos/ui/viewer/file/file_viewer_image_page_readiness.dart";import "package:photos/ui/viewer/file/live_image_long_press_router.dart";import "package:photos/ui/viewer/file/qr_code_detection_helper.dart";import 'package:photos/ui/viewer/file/zoomable_image.dart';@@ -30,6 +31,8 @@ class ZoomableLiveImageNew extends StatefulWidget {final bool isFromMemories;final Function({required int memoryDuration})? onFinalFileLoad;final ValueChanged<File>? onFinalImageLoaded;+ final FileViewerImagePageReadinessRegistration?+ onImagePageReadinessRegistration;final ValueNotifier<QrCodeDetectionResult?>? qrDetectionsNotifier;final GestureLongPressStartCallback? onTextSelectionStart;@@ -42,6 +45,7 @@ class ZoomableLiveImageNew extends StatefulWidget {this.isFromMemories = false,this.onFinalFileLoad,this.onFinalImageLoaded,+ this.onImagePageReadinessRegistration,this.qrDetectionsNotifier,this.onTextSelectionStart,});@@ -200,6 +204,7 @@ class _ZoomableLiveImageNewState extends State<ZoomableLiveImageNew>isFromMemories: widget.isFromMemories,onFinalFileLoad: widget.onFinalFileLoad,onFinalImageLoaded: widget.onFinalImageLoaded,+ onImagePageReadinessRegistration: widget.onImagePageReadinessRegistration,);final shouldShowVideo =diff --git a/mobile/apps/photos/test/ui/viewer/file/file_viewer_filmstrip_coordinator_test.dart b/mobile/apps/photos/test/ui/viewer/file/file_viewer_filmstrip_coordinator_test.dartindex 8429db9474..018ebfcbd8 100644--- a/mobile/apps/photos/test/ui/viewer/file/file_viewer_filmstrip_coordinator_test.dart+++ b/mobile/apps/photos/test/ui/viewer/file/file_viewer_filmstrip_coordinator_test.dart@@ -100,6 +100,72 @@ void main() {expect(harness.paintBarriers, isEmpty);});+ test("an image commit waits for its decoded frame before painting", () {+ final harness = _CoordinatorHarness(waitsForImageFrame: true);+ final readiness = ValueNotifier(false);+ addTearDown(harness.dispose);+ addTearDown(() {+ harness.coordinator.detachImagePage(harness.identities[8], readiness);+ readiness.dispose();+ });+ harness.coordinator.attachImagePage(harness.identities[8], readiness);++ harness.send(7, FileViewerFilmstripEventType.scrubStart);+ harness.send(8, FileViewerFilmstripEventType.scrubPreview);+ harness.send(8, FileViewerFilmstripEventType.scrubCommit);++ expect(harness.selectedIndex, 8);+ expect(harness.coordinator.previewIndex.value, 8);+ expect(harness.paintBarriers, isEmpty);++ readiness.value = true;++ expect(harness.paintBarriers, hasLength(1));+ harness.paintBarriers.single();+ expect(harness.coordinator.previewIndex.value, isNull);+ });++ test("an image decoded before commit schedules its paint handoff", () {+ final harness = _CoordinatorHarness(waitsForImageFrame: true);+ final readiness = ValueNotifier(true);+ addTearDown(harness.dispose);+ addTearDown(() {+ harness.coordinator.detachImagePage(harness.identities[8], readiness);+ readiness.dispose();+ });+ harness.coordinator.attachImagePage(harness.identities[8], readiness);++ harness.send(7, FileViewerFilmstripEventType.scrubStart);+ harness.send(8, FileViewerFilmstripEventType.scrubPreview);+ harness.send(8, FileViewerFilmstripEventType.scrubCommit);++ expect(harness.selectedIndex, 8);+ expect(harness.coordinator.previewIndex.value, 8);+ expect(harness.paintBarriers, hasLength(1));+ harness.paintBarriers.single();+ expect(harness.coordinator.previewIndex.value, isNull);+ });++ test("readiness from a detached image page is not retained", () {+ final harness = _CoordinatorHarness(waitsForImageFrame: true);+ final readiness = ValueNotifier(false);+ addTearDown(harness.dispose);+ addTearDown(readiness.dispose);++ harness.coordinator.attachImagePage(harness.identities[8], readiness);+ harness.coordinator.detachImagePage(harness.identities[8], readiness);+ harness.send(7, FileViewerFilmstripEventType.scrubStart);+ harness.send(8, FileViewerFilmstripEventType.scrubPreview);+ harness.send(8, FileViewerFilmstripEventType.scrubCommit);++ expect(harness.selectedIndex, 8);+ expect(harness.coordinator.previewIndex.value, 8);+ expect(harness.paintBarriers, isEmpty);++ readiness.value = true;+ expect(harness.paintBarriers, isEmpty);+ });+test("a stale paint barrier cannot clear a newer scrub preview", () {final harness = _CoordinatorHarness();addTearDown(harness.dispose);@@ -208,13 +274,17 @@ class _CoordinatorHarness {final List<int> jumps = [];final List<VoidCallback> paintBarriers = [];final bool synchronousPageChanges;+ final bool waitsForImageFrame;late final FileViewerFilmstripCoordinator coordinator;int selectedIndex = 7;int pauseCount = 0;bool pageAttached = true;- _CoordinatorHarness({this.synchronousPageChanges = true}) {+ _CoordinatorHarness({+ this.synchronousPageChanges = true,+ this.waitsForImageFrame = false,+ }) {coordinator = FileViewerFilmstripCoordinator(currentIndex: () => selectedIndex,identityAt: (index) =>@@ -229,6 +299,7 @@ class _CoordinatorHarness {return true;},requestPauseCurrentMedia: () => pauseCount++,+ waitsForImageFrame: (_) => waitsForImageFrame,scheduleAfterNextFramePaint: paintBarriers.add,);}diff --git a/mobile/apps/photos/test/ui/viewer/file/image_zoom/image_zoom_viewer_test.dart b/mobile/apps/photos/test/ui/viewer/file/image_zoom/image_zoom_viewer_test.dartindex a896ba7c42..0f39311865 100644--- a/mobile/apps/photos/test/ui/viewer/file/image_zoom/image_zoom_viewer_test.dart+++ b/mobile/apps/photos/test/ui/viewer/file/image_zoom/image_zoom_viewer_test.dart@@ -39,6 +39,22 @@ void main() {largerLandscapeImage.dispose();});+ testWidgets("reports when the first image frame is decoded", (tester) async {+ var readyCount = 0;++ await tester.pumpWidget(+ MaterialApp(+ home: ImageZoomViewer(+ imageProvider: _DeterministicImageProvider(landscapeImage),+ onImageFrameReady: () => readyCount++,+ ),+ ),+ );+ await tester.pump();++ expect(readyCount, 1);+ });+group("double-tap focal zoom", () {testWidgets("centers the tapped horizontal area", (tester) async {final harness = await _pumpViewer(tester, image: landscapeImage);