RESOLVED FIXED 223530
Ignore middle commits during animated resize
https://bugs.webkit.org/show_bug.cgi?id=223530
Summary Ignore middle commits during animated resize
Sihui Liu
Reported 2021-03-19 11:48:18 PDT
...
Attachments
Patch (4.85 KB, patch)
2021-03-19 12:08 PDT, Sihui Liu
no flags
Patch (5.71 KB, patch)
2021-03-22 16:18 PDT, Sihui Liu
no flags
Patch (5.72 KB, patch)
2021-03-23 13:09 PDT, Sihui Liu
no flags
Sihui Liu
Comment 1 2021-03-19 12:08:59 PDT
Sam Weinig
Comment 2 2021-03-19 12:44:57 PDT
It seems like adding SPI for this would only help Safari? Can we instead infer we are in this state somehow instead? Or if really can’t, seems like it should probably be API instead.
Tim Horton
Comment 3 2021-03-19 15:29:55 PDT
I wonder if this is not equivalent to the client calling endAnimatedResize from a doAfterNextPresentationUpdate:^{} block?? It seems like it might be.
Tim Horton
Comment 4 2021-03-19 15:31:00 PDT
(In reply to Sam Weinig from comment #2) > It seems like adding SPI for this would only help Safari? Can we instead > infer we are in this state somehow instead? Or if really can’t, seems like > it should probably be API instead. Animated resize is SPI, so this doesn't make sense.
Sihui Liu
Comment 5 2021-03-19 16:20:53 PDT
(In reply to Tim Horton from comment #3) > I wonder if this is not equivalent to the client calling endAnimatedResize > from a doAfterNextPresentationUpdate:^{} block?? It seems like it might be. It may be the same. I thought about delaying endAnimatedResize but don't know how much we are going to delay. Let me test if doAfterNextPresentationUpdate:^{} fixes the problem.
Sam Weinig
Comment 6 2021-03-20 11:52:37 PDT
(In reply to Tim Horton from comment #4) > (In reply to Sam Weinig from comment #2) > > It seems like adding SPI for this would only help Safari? Can we instead > > infer we are in this state somehow instead? Or if really can’t, seems like > > it should probably be API instead. > > Animated resize is SPI, so this doesn't make sense. Can you elaborate on what you mean by this?
Tim Horton
Comment 7 2021-03-20 12:50:53 PDT
(In reply to Sam Weinig from comment #6) > (In reply to Tim Horton from comment #4) > > (In reply to Sam Weinig from comment #2) > > > It seems like adding SPI for this would only help Safari? Can we instead > > > infer we are in this state somehow instead? Or if really can’t, seems like > > > it should probably be API instead. > > > > Animated resize is SPI, so this doesn't make sense. > > Can you elaborate on what you mean by this? (I was responding to the last sentence; the second one makes sense to me; the first one is just wrong, this isn’t about Safari, but other SPI clients). Animated resize is SPI so it doesn’t make sense to make a mechanism to control a detail of it API? It’s possible you meant that the whole animated resize SPI should become API (and I vaguely agree), but as it stands the SPI is poorly designed, confusing, and easy to misuse, so that’s a much bigger project.
Sihui Liu
Comment 8 2021-03-21 20:57:43 PDT
It seems we can fix the issue with doAfterNextPresentationUpdate like Tim said, so we don't need the SPI!
Sihui Liu
Comment 9 2021-03-22 01:11:21 PDT
Nope, _doAfterNextPresentationUpdate will invoke callback after ongoing animated resize (see - (void)_internalDoAfterNextPresentationUpdate:(void (^)(void))updateBlock withoutWaitingForPainting:(BOOL)withoutWaitingForPainting withoutWaitingForAnimatedResize:(BOOL)withoutWaitingForAnimatedResize), so if we put _endAnimatedResize in the callback the animated resize will never be ended.
Tim Horton
Comment 10 2021-03-22 01:17:43 PDT
(In reply to Sihui Liu from comment #9) > Nope, _doAfterNextPresentationUpdate will invoke callback after ongoing > animated resize (see - (void)_internalDoAfterNextPresentationUpdate:(void > (^)(void))updateBlock > withoutWaitingForPainting:(BOOL)withoutWaitingForPainting > withoutWaitingForAnimatedResize:(BOOL)withoutWaitingForAnimatedResize), so > if we put _endAnimatedResize in the callback the animated resize will never > be ended. Oh, geez.
Sihui Liu
Comment 11 2021-03-22 16:18:52 PDT
Tim Horton
Comment 12 2021-03-22 16:26:37 PDT
Comment on attachment 423957 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=423957&action=review > Source/WebKit/ChangeLog:16 > + _waitingForEndAnimatedResize. In this case, let's just ignore middle commits and remove corresponding code. >Safari, also doesn't hit the adative scaling path because it always early returns at _waitingForEndAnimatedResize Doesn't this just mean that you haven't won the race in your testing?? (receiving a commit /after/ Safari calls -endAnimatedResize)
Tim Horton
Comment 13 2021-03-22 16:27:36 PDT
(In reply to Tim Horton from comment #12) > Comment on attachment 423957 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=423957&action=review > > > Source/WebKit/ChangeLog:16 > > + _waitingForEndAnimatedResize. In this case, let's just ignore middle commits and remove corresponding code. > > >Safari, also doesn't hit the adative scaling path because it always early returns at _waitingForEndAnimatedResize > > Doesn't this just mean that you haven't won the race in your testing?? > (receiving a commit /after/ Safari calls -endAnimatedResize) (you could probably win the race by either using slower hardware or putting a short sleep in `RemoteLayerTreeDrawingArea::BackingStoreFlusher::flush` before the call to `sendMessage`)
Sihui Liu
Comment 14 2021-03-22 16:32:56 PDT
(In reply to Tim Horton from comment #13) > (In reply to Tim Horton from comment #12) > > Comment on attachment 423957 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=423957&action=review > > > > > Source/WebKit/ChangeLog:16 > > > + _waitingForEndAnimatedResize. In this case, let's just ignore middle commits and remove corresponding code. > > > > >Safari, also doesn't hit the adative scaling path because it always early returns at _waitingForEndAnimatedResize > > > > Doesn't this just mean that you haven't won the race in your testing?? > > (receiving a commit /after/ Safari calls -endAnimatedResize) > > (you could probably win the race by either using slower hardware or putting > a short sleep in `RemoteLayerTreeDrawingArea::BackingStoreFlusher::flush` > before the call to `sendMessage`) (In reply to Tim Horton from comment #12) > Comment on attachment 423957 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=423957&action=review > > > Source/WebKit/ChangeLog:16 > > + _waitingForEndAnimatedResize. In this case, let's just ignore middle commits and remove corresponding code. > > >Safari, also doesn't hit the adative scaling path because it always early returns at _waitingForEndAnimatedResize > > Doesn't this just mean that you haven't won the race in your testing?? > (receiving a commit /after/ Safari calls -endAnimatedResize) Yes, I don't see commits arrive after Safari calls endAnimatedResize during testing, so I am not sure whether that can happen in a real-world use case. Will try sleep in RemoteLayerTreeDrawingArea::BackingStoreFlusher::flush() a bit.
Tim Horton
Comment 15 2021-03-22 16:48:01 PDT
(In reply to Sihui Liu from comment #14) > (In reply to Tim Horton from comment #13) > > (In reply to Tim Horton from comment #12) > > > Comment on attachment 423957 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=423957&action=review > > > > > > > Source/WebKit/ChangeLog:16 > > > > + _waitingForEndAnimatedResize. In this case, let's just ignore middle commits and remove corresponding code. > > > > > > >Safari, also doesn't hit the adative scaling path because it always early returns at _waitingForEndAnimatedResize > > > > > > Doesn't this just mean that you haven't won the race in your testing?? > > > (receiving a commit /after/ Safari calls -endAnimatedResize) > > > > (you could probably win the race by either using slower hardware or putting > > a short sleep in `RemoteLayerTreeDrawingArea::BackingStoreFlusher::flush` > > before the call to `sendMessage`) > > (In reply to Tim Horton from comment #12) > > Comment on attachment 423957 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=423957&action=review > > > > > Source/WebKit/ChangeLog:16 > > > + _waitingForEndAnimatedResize. In this case, let's just ignore middle commits and remove corresponding code. > > > > >Safari, also doesn't hit the adative scaling path because it always early returns at _waitingForEndAnimatedResize > > > > Doesn't this just mean that you haven't won the race in your testing?? > > (receiving a commit /after/ Safari calls -endAnimatedResize) > > Yes, I don't see commits arrive after Safari calls endAnimatedResize during > testing, so I am not sure whether that can happen in a real-world use case. There is no connection between the two (a commit can be arbitrarily delayed in the WP, on a secondary queue, which is what you're going to test), so it should /totally/ be possible.
Sihui Liu
Comment 16 2021-03-23 09:55:23 PDT
(In reply to Tim Horton from comment #15) > (In reply to Sihui Liu from comment #14) > > (In reply to Tim Horton from comment #13) > > > (In reply to Tim Horton from comment #12) > > > > Comment on attachment 423957 [details] > > > > Patch > > > > > > > > View in context: > > > > https://bugs.webkit.org/attachment.cgi?id=423957&action=review > > > > > > > > > Source/WebKit/ChangeLog:16 > > > > > + _waitingForEndAnimatedResize. In this case, let's just ignore middle commits and remove corresponding code. > > > > > > > > >Safari, also doesn't hit the adative scaling path because it always early returns at _waitingForEndAnimatedResize > > > > > > > > Doesn't this just mean that you haven't won the race in your testing?? > > > > (receiving a commit /after/ Safari calls -endAnimatedResize) > > > > > > (you could probably win the race by either using slower hardware or putting > > > a short sleep in `RemoteLayerTreeDrawingArea::BackingStoreFlusher::flush` > > > before the call to `sendMessage`) > > > > (In reply to Tim Horton from comment #12) > > > Comment on attachment 423957 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=423957&action=review > > > > > > > Source/WebKit/ChangeLog:16 > > > > + _waitingForEndAnimatedResize. In this case, let's just ignore middle commits and remove corresponding code. > > > > > > >Safari, also doesn't hit the adative scaling path because it always early returns at _waitingForEndAnimatedResize > > > > > > Doesn't this just mean that you haven't won the race in your testing?? > > > (receiving a commit /after/ Safari calls -endAnimatedResize) > > > > Yes, I don't see commits arrive after Safari calls endAnimatedResize during > > testing, so I am not sure whether that can happen in a real-world use case. > > There is no connection between the two (a commit can be arbitrarily delayed > in the WP, on a secondary queue, which is what you're going to test), so it > should /totally/ be possible. I see. With 1s sleep in RemoteLayerTreeDrawingArea::BackingStoreFlusher::flush() I can reproduce the case where middle commits (commits before animated size update and arrive in UI process after beginAnimatedResize) arrive after endAnimatedResize. And it seems removing the code is the correct behavior in Safari, otherwise we can stretch too much.
Sihui Liu
Comment 17 2021-03-23 13:09:00 PDT
Tim Horton
Comment 18 2021-03-24 00:30:15 PDT
Comment on attachment 424053 [details] Patch Given the results of Sihui's experiments, let's give it a shot.
Radar WebKit Bug Importer
Comment 19 2021-03-24 09:31:44 PDT
EWS
Comment 20 2021-03-24 09:45:16 PDT
Committed r274941: <https://commits.webkit.org/r274941> All reviewed patches have been landed. Closing bug and clearing flags on attachment 424053 [details].
Note You need to log in before you can comment on or make changes to this bug.