Bug 210297 - First render after a process swap does not use accelerated rendering
Summary: First render after a process swap does not use accelerated rendering
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-09 13:00 PDT by Chris Dumez
Modified: 2020-04-10 14:00 PDT (History)
7 users (show)

See Also:


Attachments
Proof of concept fix (15.72 KB, patch)
2020-04-09 13:02 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Proof of concept fix (14.64 KB, patch)
2020-04-09 13:27 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Proof of concept fix (13.80 KB, patch)
2020-04-09 13:29 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Proof of concept fix (13.64 KB, patch)
2020-04-09 13:31 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (24.26 KB, patch)
2020-04-09 13:50 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (24.68 KB, patch)
2020-04-09 14:05 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (29.01 KB, patch)
2020-04-09 14:22 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
test case for drawInContext: on hidden layer (2.85 KB, text/x-csrc)
2020-04-10 11:48 PDT, Ben Nham
no flags Details
Patch (29.15 KB, patch)
2020-04-10 12:14 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-04-09 13:00:50 PDT
First render after a process swap does not use accelerated rendering.
Comment 1 Chris Dumez 2020-04-09 13:01:09 PDT
<rdar://problem/61432515>
Comment 2 Chris Dumez 2020-04-09 13:02:12 PDT
Created attachment 395993 [details]
Proof of concept fix

I have a proof of concept that seems to be the issue (would need some cleanup though). I am uploading the gather early feedback.
Comment 3 Chris Dumez 2020-04-09 13:27:39 PDT
Created attachment 395997 [details]
Proof of concept fix
Comment 4 Chris Dumez 2020-04-09 13:29:56 PDT
Created attachment 395998 [details]
Proof of concept fix
Comment 5 Chris Dumez 2020-04-09 13:31:02 PDT
Created attachment 395999 [details]
Proof of concept fix
Comment 6 Chris Dumez 2020-04-09 13:50:12 PDT
Created attachment 396004 [details]
WIP Patch
Comment 7 Chris Dumez 2020-04-09 14:05:37 PDT
Created attachment 396006 [details]
WIP Patch

Ok, I did a decent amount of cleanup and it appears to be working. Any early feedback?
Comment 8 Chris Dumez 2020-04-09 14:22:16 PDT
Created attachment 396010 [details]
Patch
Comment 9 Geoffrey Garen 2020-04-09 17:38:56 PDT
Are the EWS crashes in viewgesturecontroller real?
Comment 10 Antti Koivisto 2020-04-10 07:31:49 PDT
Comment on attachment 396010 [details]
Patch

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

Good idea!

> Source/WebKit/ChangeLog:26
> +        2. In the UIProcess, when we get the DrawingAreaProxy::EnterAcceleratedCompositingMode
> +           IPC and we already have a root layer, we add the new one behind the existing one
> +           instead of replacing the existing one. As a result, the new layer will get
> +           accelerated compositing but will not be visible on screen yet.

I wonder if there are cases with transparent layers or missing tiles where this could lead to both pages being partially visible at the same time.

Maybe a stronger hiding strategy is needed?
Comment 11 Chris Dumez 2020-04-10 08:06:29 PDT
(In reply to Geoffrey Garen from comment #9)
> Are the EWS crashes in viewgesturecontroller real?

EWS is green now so I guess not.
Comment 12 Chris Dumez 2020-04-10 08:07:06 PDT
(In reply to Antti Koivisto from comment #10)
> Comment on attachment 396010 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=396010&action=review
> 
> Good idea!
> 
> > Source/WebKit/ChangeLog:26
> > +        2. In the UIProcess, when we get the DrawingAreaProxy::EnterAcceleratedCompositingMode
> > +           IPC and we already have a root layer, we add the new one behind the existing one
> > +           instead of replacing the existing one. As a result, the new layer will get
> > +           accelerated compositing but will not be visible on screen yet.
> 
> I wonder if there are cases with transparent layers or missing tiles where
> this could lead to both pages being partially visible at the same time.
> 
> Maybe a stronger hiding strategy is needed?

Tim / Simon, what do you think? Can I land as is or do you think we need a better hiding strategy?
Comment 13 Simon Fraser (smfr) 2020-04-10 10:25:03 PDT
(In reply to Chris Dumez from comment #12)
> (In reply to Antti Koivisto from comment #10)
> > Comment on attachment 396010 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=396010&action=review
> > 
> > Good idea!
> > 
> > > Source/WebKit/ChangeLog:26
> > > +        2. In the UIProcess, when we get the DrawingAreaProxy::EnterAcceleratedCompositingMode
> > > +           IPC and we already have a root layer, we add the new one behind the existing one
> > > +           instead of replacing the existing one. As a result, the new layer will get
> > > +           accelerated compositing but will not be visible on screen yet.
> > 
> > I wonder if there are cases with transparent layers or missing tiles where
> > this could lead to both pages being partially visible at the same time.
> > 
> > Maybe a stronger hiding strategy is needed?
> 
> Tim / Simon, what do you think? Can I land as is or do you think we need a
> better hiding strategy?

We do. WKWebViews can be transparent, which allows transparent page contents, and this hack would make your hidden views visible.

Maybe move them offscreen? Or set layer.hidden (checking to see whether that cuts of painting, which we don't want).
Comment 14 Simon Fraser (smfr) 2020-04-10 10:26:13 PDT
There's a menu item in MiniBrowser to toggle on transparent web views. Navigate from a page with no root background color; you shouldn't see the new page behind the old one.

Ideally this would be testable.
Comment 15 Ben Nham 2020-04-10 11:48:19 PDT
Created attachment 396111 [details]
test case for drawInContext: on hidden layer

Based on code inspection of CALayer.mm and this attached test case, it seems like -drawInContext: still gets called on a layer even if it's hidden. But we could ask the CA maintainer to be sure.
Comment 16 Chris Dumez 2020-04-10 12:07:54 PDT
(In reply to Ben Nham from comment #15)
> Created attachment 396111 [details]
> test case for drawInContext: on hidden layer
> 
> Based on code inspection of CALayer.mm and this attached test case, it seems
> like -drawInContext: still gets called on a layer even if it's hidden. But
> we could ask the CA maintainer to be sure.

Yes, I have also verified in Safari that marking the layer as hidden does not prevent painting or hardware acceleration.
Comment 17 Chris Dumez 2020-04-10 12:14:04 PDT
Created attachment 396112 [details]
Patch
Comment 18 EWS 2020-04-10 13:30:08 PDT
Committed r259898: <https://trac.webkit.org/changeset/259898>

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