Bug 217737 - Twitter Photo gallery incorrectly rendered after opening another modal
Summary: Twitter Photo gallery incorrectly rendered after opening another modal
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL: https://mobile.twitter.com/?tts_token...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-14 16:25 PDT by Charlie Croom
Modified: 2020-10-22 20:16 PDT (History)
15 users (show)

See Also:


Attachments
Layout capture after bug; highlighted area is container of background-image (1.37 MB, image/png)
2020-10-14 16:25 PDT, Charlie Croom
no flags Details
Patch (14.76 KB, patch)
2020-10-22 13:27 PDT, Simon Fraser (smfr)
zalan: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Charlie Croom 2020-10-14 16:25:29 PDT
Created attachment 411385 [details]
Layout capture after bug; highlighted area is container of background-image

On twitter.com, we encountered a strange rendering bug when working on our photo gallery modal which causes the layout to incorrectly render when coming back to the gallery. 

Reproduce:
- Open this special link which removes our production workaround: . (Because this is an internal build, it's only available for 3 days at a time, but you can reach out to me to get a new one.)
- Go to a Tweet with a photo gallery: https://twitter.com/CharlieCroom/status/968880712286793728
- Open the gallery
- At the bottom is a reply icon, click it to open the composer
- Click the x in the top left of the composer to click it

Expected:
- Gallery renders normally

Actual:
- Gallery renders all messed up (see attachment)

To work around this in production, we've added `borderRadius: '0.01px'` to the dialog element. (It should have aria-modal="true")
Comment 1 Simon Fraser (smfr) 2020-10-14 16:41:38 PDT
(In reply to Charlie Croom from comment #0)
> Reproduce:
> - Open this special link which removes our production workaround: . (Because
> this is an internal build, it's only available for 3 days at a time, but you
> can reach out to me to get a new one.)

Did you forget the link?
Comment 2 Charlie Croom 2020-10-14 17:04:48 PDT
Current staging URL: https://mobile.twitter.com/?tts_token=Hy2Ncdql0yMKW0Hs
Comment 3 Charlie Croom 2020-10-14 17:05:08 PDT
Yes I did lol. Forgot to wait for it to stage.
Comment 4 Simon Fraser (smfr) 2020-10-14 17:19:50 PDT
I can reproduce.
Comment 5 Radar WebKit Bug Importer 2020-10-14 17:20:09 PDT
<rdar://problem/70314822>
Comment 6 Simon Fraser (smfr) 2020-10-20 15:08:49 PDT
Could I get a new staging URL please?

> To work around this in production, we've added `borderRadius: '0.01px'` to the dialog element. (It should have aria-modal="true")

Which element is that? Is it a dialog for the reply, or for the gallery?
Comment 7 Charlie Croom 2020-10-20 15:42:45 PDT
(In reply to Simon Fraser (smfr) from comment #6)
> Could I get a new staging URL please?

https://mobile.twitter.com/?tts_token=ksII522TMwUrIm6u

> > To work around this in production, we've added `borderRadius: '0.01px'` to the dialog element. (It should have aria-modal="true")
> 
> Which element is that? Is it a dialog for the reply, or for the gallery?
This is in the dialog for the galleryn, it's currently .r-1pp0k63 for me in prod, but that may change...so you can also look for aria-labelledby="modal-header" which points to the element
Comment 8 Amy Simmons 2020-10-20 19:20:47 PDT
Hi,

In case this additional info helps. These are some notes I took at the time we added the border radius of 0.01px.

What we know about the bug:

- Only happens in Safari
- Only happens after exiting the Reply or RT with comment tweet actions, does not happen after exiting the Send via DM tweet action
- Only happens on tweets with multiple images, not on single images
- Only happens when pressing the 'X' to dismiss the tweet action, does not happen when pressing the mask to go back
- After some playing around, you can no longer reproduce the issue, and need to close Safari and re-open in order to reproduce it again 

How I got to the borderRadius 0.01px solution:

- I had been working on a series of enhancements to the media viewer, one of which was making it full screen (previously it was not a full screen modal)
- I checked out several of my changes to see at what point the bug was introduced. It was introduced in the very first ticket, where I changed the width and height of the modal to make it full screen and removed the border radius
- Previously, all modals had a border radius. But with the new full screen modal, we no longer needed a border radius. So when I implemented the full screen modal I chose to only add a border radius when the modal size was something other than 'full'. Eg the compose modal would have the border radius, but the full screen media modal would not.
- I don't understand why adding the borderRadius of 0.01px back in fixes the bug, why it was only an issue for the Reply or RT with Comment tweet actions (not the Send via DM tweet action), or why it was only an issue when clicking the X to dismiss, rather than the mask.
Comment 9 Simon Fraser (smfr) 2020-10-20 20:20:05 PDT
Thanks for the extra info, Amy, that's useful. I suspect it's a bug in our compositing code. I'll debug using the staging URL.
Comment 10 Amy Simmons 2020-10-21 12:12:22 PDT
Thanks Simon. Do you by chance have a rough idea of how long this might take to fix? Trying to figure out if it's worth putting in a temporary solution on our end that doesn't impact perf in the other browsers. Thanks!
Comment 11 Simon Fraser (smfr) 2020-10-21 16:57:53 PDT
This is happening because there's a path through RenderLayerBacking::updateChildClippingStrategy() that fails too clean up the rounded-rect clipping layers.
Comment 12 Simon Fraser (smfr) 2020-10-22 13:27:12 PDT
Created attachment 412124 [details]
Patch
Comment 13 Simon Fraser (smfr) 2020-10-22 13:29:41 PDT
(In reply to Amy Simmons from comment #10)
> Thanks Simon. Do you by chance have a rough idea of how long this might take
> to fix? Trying to figure out if it's worth putting in a temporary solution
> on our end that doesn't impact perf in the other browsers. Thanks!

I can't say anything about when this fix gets released.

Your 0.01px radius workaround is fine (I don't believe it has significant perf impact). Using a different element for the reply box with radius, and the gallery would also work. Or you could force a display:none update, but that would have vastly higher perf impact.
Comment 14 zalan 2020-10-22 14:49:01 PDT
Comment on attachment 412124 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=412124&action=review

nice cleanup on bool setMasksToBoundsRect()

> Source/WebCore/rendering/RenderLayerBacking.cpp:1325
> +        auto computeMasksToBoundsRect = [&]() {

[&] should do

> Source/WebCore/rendering/RenderLayerBacking.cpp:2219
> +    auto needsClipMaskLayer = [&]() {

Same here
Comment 15 Simon Fraser (smfr) 2020-10-22 16:16:27 PDT
https://trac.webkit.org/r268898