Bug 212640 - getBoundingClientRect() values in requestAnimationFrame callback different from those in Chrome and FF when using a "transform" transition
Summary: getBoundingClientRect() values in requestAnimationFrame callback different fr...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: Safari 13
Hardware: Mac macOS 10.15
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-02 09:24 PDT by ian
Modified: 2020-07-31 07:05 PDT (History)
7 users (show)

See Also:


Attachments
Repro / example (2.19 KB, text/html)
2020-06-02 09:24 PDT, ian
no flags Details
Expected behavior (Chrome) (98.21 KB, video/quicktime)
2020-06-02 10:16 PDT, ian
no flags Details
Actual behavior (Safari) (104.75 KB, video/quicktime)
2020-06-02 10:16 PDT, ian
no flags Details
Test using "left" and "top" properties (2.28 KB, text/html)
2020-07-31 06:51 PDT, Antoine Quint
no flags Details
Test using "transform" property (2.19 KB, text/html)
2020-07-31 06:52 PDT, Antoine Quint
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description ian 2020-06-02 09:24:42 PDT
Created attachment 400831 [details]
Repro / example

The values returned by getClientBoundingRect (gCBR) of an element with a transform transition, when used in requestAnimationFrame (rAF), appear to describe what is presented rather than what will be painted post rAF. 

But in Chrome and FF, gCBR values consistently match what _will be_ painted, such that gCBR can be used to perfectly align elements to other transitioning elements (see attached example in Safari and Chrome).

Reading the specs for getClientBoundingRect and requestAnimationFrame, I can't yet tell whether the data in this situation is _supposed_ to agree with what is on screen or what _will_ be on screen. The inconsistency is a paint point though.
Comment 1 ian 2020-06-02 09:33:01 PDT
Correction: In FF, if a transform transition is interrupted by writing new transform values, there appears to be one frame where the gCBR values don't align with what will be drawn.
Comment 2 ian 2020-06-02 10:16:04 PDT
Created attachment 400834 [details]
Expected behavior (Chrome)
Comment 3 ian 2020-06-02 10:16:39 PDT
Created attachment 400835 [details]
Actual behavior (Safari)
Comment 4 Radar WebKit Bug Importer 2020-06-02 18:34:57 PDT
<rdar://problem/63902988>
Comment 5 Simon Fraser (smfr) 2020-06-02 21:10:11 PDT
Interesting. We do update animations before firing rAF callbacks, but maybe we haven't competed new transforms in RenderLayer::updateTransform().

Having said that, any getBoundingClientRect should trigger a layout if necessary. But maybe the animation hasn't marked the renderer as needing layout?
Comment 6 Antoine Quint 2020-07-31 06:51:23 PDT
This does not reproduce if using the "left" and "top" properties, so this appears to be specific to accelerated transitions when using "transform".
Comment 7 Antoine Quint 2020-07-31 06:51:49 PDT
Created attachment 405687 [details]
Test using "left" and "top" properties
Comment 8 Antoine Quint 2020-07-31 06:52:09 PDT
Created attachment 405688 [details]
Test using "transform" property
Comment 9 Antoine Quint 2020-07-31 06:53:25 PDT
The "transform" test also shows the occasional flashing back to the original position after a transition completes :(
Comment 10 Antoine Quint 2020-07-31 06:57:44 PDT
The flashing could be a manifestation of bug 212637.
Comment 11 ian 2020-07-31 07:05:33 PDT
( FWIW, the same behavior occurs with getScreenCTM(). )