Skip to content

Commit 84e1ec2

Browse files
klopez4212Terp
andcommitted
Preserve animation frames over delayed initial image replies
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <[email protected]>
1 parent 8531e29 commit 84e1ec2

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎mobile/ios/NativeControlTests/NativePhotoZoomTests.swift‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ struct NativePhotoZoomTests {
3333
precondition(photo.image == nil, "Late old-window responses cannot paint the selected photo")
3434
let current = requests
3535
requests.removeAll()
36-
for request in current { request.2(FlutterStandardTypedData(bytes: data)) }
37-
precondition(photo.image != nil, "Current-window responses must paint the actual page")
3836
let blueData = UIGraphicsImageRenderer(size: CGSize(width: 2, height: 2)).pngData { context in
3937
UIColor.blue.setFill(); context.fill(CGRect(x: 0, y: 0, width: 2, height: 2))
4038
}
@@ -44,6 +42,9 @@ struct NativePhotoZoomTests {
4442
viewer.updateFrame(blueData, at: 50)
4543
precondition(photo.image !== previous, "Continuing animation frames must update the selected photo")
4644
let updated = photo.image
45+
precondition(current.contains { $0.0 == "image" && $0.1 == 50 }, "Hold the selected initial-image reply until after a continuing frame")
46+
for request in current { request.2(FlutterStandardTypedData(bytes: data)) }
47+
precondition(photo.image === updated, "Delayed initial image and preview replies must not rewind a continuing frame")
4748
viewer.updateFrame(Data([0, 1]), at: 50)
4849
precondition(photo.image === updated, "Malformed frames must preserve the last displayed image")
4950
indicator.currentPage = 0; sendValueChanged(indicator)

‎mobile/ios/Runner/NativePhotoZoomCoordinator.swift‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ private final class NativePhotoZoomViewController: UIViewController, UIPageViewC
336336
guard let self, !self.finishing, self.isNearby(value), self.pending[key] == token else { return }
337337
self.pending.removeValue(forKey: key)
338338
let image = (result as? FlutterStandardTypedData).flatMap { UIImage(data: $0.data) }
339-
if let image {
339+
// A continuing frame can arrive before this initial reply. Keep the
340+
// newer full image authoritative over both delayed image and preview data.
341+
if let image, self.images[value] == nil {
340342
if method == "preview" { self.previews[value] = image }
341343
else { self.images[value] = image }
342344
}

0 commit comments

Comments
 (0)