Bug 211505 - REGRESSION (r253875?): Element styles incorrect after media query evaluation changes
Summary: REGRESSION (r253875?): Element styles incorrect after media query evaluation ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 13
Hardware: Mac macOS 10.15
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-06 05:44 PDT by James Brooks
Modified: 2020-06-05 09:30 PDT (History)
10 users (show)

See Also:


Attachments
A video demonstrating the bug in Safari 13.1 (12.49 MB, video/quicktime)
2020-05-06 05:44 PDT, James Brooks
no flags Details
Basic recreation of the issue (1.32 KB, text/html)
2020-05-08 03:14 PDT, James Brooks
no flags Details
patch (6.77 KB, patch)
2020-06-05 04:54 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Brooks 2020-05-06 05:44:53 PDT
Created attachment 398603 [details]
A video demonstrating the bug in Safari 13.1

Media queries don't always yield the expected results when resizing my browser window. I have a media query that repositions two divs side-by-side on screen sizes wider the 900px, and on mobile they stack on top of each other. When resizing up from mobile the styles don't update until the page is reloaded. The media queries behave as expected on both Safari 13.0 and Safari 12.1, this issue only seems to be present in Safari 13.1.

The release notes for Safari 13.1 contained the extract:
> Made media query updates more efficient.

I traced that back to the equivalent Safari Technical Preview release notes and found:
> Improved performance by invalidating only affected elements after media query evaluation changes

I think the issues I am seeing are linked to the changes made in r253875 as a result of bug 205392.

I have also been able to validate that the issue is still present on the most recent WebKit build archive at the time of writing this r261218.
Comment 1 Radar WebKit Bug Importer 2020-05-07 10:52:32 PDT
<rdar://problem/62983242>
Comment 2 Antti Koivisto 2020-05-08 01:05:13 PDT
Can you attach the test case?
Comment 3 James Brooks 2020-05-08 03:14:46 PDT
Created attachment 398850 [details]
Basic recreation of the issue
Comment 4 James Brooks 2020-05-08 03:15:07 PDT
I've attached a minimal reproduction similar to the video above - let me know if you need something more specific.

I also spent a bit more time looking into the cause and it seems like the inclusion of a @keyframes rule inside of the media query is at fault in this example. This was a mistake on my part and moving the rule outside of the media query appears to result in the expected behaviour.

I do still think there's a regression here though - in the first instance the @keyframes rule was in a different media query to the one where I had noticed the issue so it seems that this was causing issues with invalidating styles across the tree rather than just the query containing the @keyframes rule? And as I mentioned in the original report, this doesn't appear to have been an issue prior to Safari 13.1.
Comment 5 Antti Koivisto 2020-05-08 09:18:46 PDT
Thanks for the repro. Interesting that it is triggered by an unused @keyframes rule inside @media.
Comment 6 James Brooks 2020-05-08 09:55:41 PDT
Agreed. Not been able to confirm if any other at-rules have the same outcome. I think I used an @supports rule in the repro which didn't seem to cause any problems?
Comment 7 Antti Koivisto 2020-06-05 04:54:10 PDT
Created attachment 401141 [details]
patch
Comment 8 EWS 2020-06-05 07:39:12 PDT
Committed r262618: <https://trac.webkit.org/changeset/262618>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401141 [details].