From 19540b3596c4637712d680b22e9f1626862ac6a3 Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Tue, 5 Oct 2021 15:51:36 -0400 Subject: [PATCH 1/2] Use targetTimestamp in SDDisplayLink --- SDWebImage/Private/SDDisplayLink.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SDWebImage/Private/SDDisplayLink.m b/SDWebImage/Private/SDDisplayLink.m index 8ff0fc16..6cf08159 100644 --- a/SDWebImage/Private/SDDisplayLink.m +++ b/SDWebImage/Private/SDDisplayLink.m @@ -89,7 +89,12 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt #elif SD_IOS || SD_TV #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - NSTimeInterval duration = self.displayLink.duration * self.displayLink.frameInterval; + NSTimeInterval duration = 0; + if (@available(iOS 10.0, *)) { + duration = self.displayLink.targetTimestamp - CACurrentMediaTime(); + } else { + duration = self.displayLink.duration * self.displayLink.frameInterval; + } #pragma clang diagnostic pop #else NSTimeInterval duration = 0; From 0076d8c447537205b8602fdc17cef82b5b21702c Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Tue, 5 Oct 2021 16:18:00 -0400 Subject: [PATCH 2/2] Add negative duration check for unit tests - The new`targetTimestamp` property causes the duration to be a negative value during the unit tests. Added an additional check to handle this case. --- SDWebImage/Private/SDDisplayLink.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDWebImage/Private/SDDisplayLink.m b/SDWebImage/Private/SDDisplayLink.m index 6cf08159..39371794 100644 --- a/SDWebImage/Private/SDDisplayLink.m +++ b/SDWebImage/Private/SDDisplayLink.m @@ -103,7 +103,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt duration = nextFireDate - self.currentFireDate; } #endif - if (duration == 0) { + if (duration <= 0) { duration = kSDDisplayLinkInterval; } return duration;