Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI-side compositing] [GPU Process] Emailing a webpage from Safari causes the tab to stop rendering #12130

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

whsieh
Copy link
Member

@whsieh whsieh commented Mar 29, 2023

e74572e

[UI-side compositing] [GPU Process] Emailing a webpage from Safari causes the tab to stop rendering
https://bugs.webkit.org/show_bug.cgi?id=254683
rdar://107329972

Reviewed by Simon Fraser.

When sharing a webpage via Mail, Safari first generates a web archive from the existing web view's
content, and then creates an offscreen web view *backed by the tab's existing web process*, which we
then use to load the web archive and perform reader extraction heuristics.

However, when the DOM GPU process experimental feature flag is enabled for Safari tabs, it only
affects the web view used for rendering the main page content; importantly, this related web view
does not have DOM GPUP enabled.

When subsequently loading the web archive data via this reader web view, we end up *disabling* GPUP
for DOM rendering in the original tab's web process, due to the following code:

```
bool usingGPUProcessForDOMRendering = m_shouldRenderDOMInGPUProcess && DrawingArea::supportsGPUProcessRendering(m_drawingAreaType);
WebProcess::singleton().setUseGPUProcessForDOMRendering(usingGPUProcessForDOMRendering);
```

The current implementation of GPUP for DOM rendering doesn't handle on-the-fly GPUP disablement —
and in fact, in the case where IOKit has already been blocked in the web process, it's impossible to
disable GPUP at all once a page has been created with all the relevant GPUP flags enabled.

As such, we mitigate this by simply forcing DOM GPUP to be enabled (regardless of preferences state)
for a web view, if its related web view already has DOM GPUP enabled. Once DOM GPUP is enabled by
default, this won't be an issue anyway, since all web views will be created with consistent feature
flag statuses.

Test: GPUProcess.GPUProcessForDOMRenderingCarriesOverFromRelatedPage

* Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::useGPUProcessForDOMRenderingEnabled const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:
(-[NSUserDefaults swizzled_objectForKey:]):
(TestWebKitAPI::EnableUISideCompositingScope::EnableUISideCompositingScope):
(TestWebKitAPI::EnableUISideCompositingScope::~EnableUISideCompositingScope):

Add a new RAII helper class to temporarily swizzle out `-objectForKey:`, in order to forcibly enable
UI-side compositing for this test, as it's necessary to exercise the bug fix. Note that I'm using
swizzling here to avoid also enabling UI-side compositing for downstream API tests, even if the test
crashes or times out.

(TestWebKitAPI::TEST):
(convertToCGImage): Deleted.
(getPixelIndex): Deleted.
(TEST): Deleted.
(runMemoryPressureExitTest): Deleted.
(waitUntilCaptureState): Deleted.

Canonical link: https://commits.webkit.org/262296@main

404f156

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2
✅ 🧪 webkitperl 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🛠 gtk
✅ 🧪 api-ios ✅ 🧪 mac-wk1 🧪 gtk-wk2
✅ 🛠 tv ✅ 🧪 mac-wk2 🧪 api-gtk
✅ 🛠 tv-sim 🧪 mac-AS-debug-wk2
✅ 🛠 watch ✅ 🧪 mac-wk2-stress
✅ 🛠 🧪 merge ✅ 🛠 watch-sim

@whsieh whsieh requested a review from cdumez as a code owner March 29, 2023 20:43
@whsieh whsieh self-assigned this Mar 29, 2023
@whsieh whsieh added the Platform Portability improvements and other general platform improvements not driven directly by site bugs. label Mar 29, 2023
@whsieh
Copy link
Member Author

whsieh commented Mar 29, 2023

Thanks for the review!

@whsieh whsieh added the merge-queue Applied to send a pull request to merge-queue label Mar 29, 2023
…uses the tab to stop rendering

https://bugs.webkit.org/show_bug.cgi?id=254683
rdar://107329972

Reviewed by Simon Fraser.

When sharing a webpage via Mail, Safari first generates a web archive from the existing web view's
content, and then creates an offscreen web view *backed by the tab's existing web process*, which we
then use to load the web archive and perform reader extraction heuristics.

However, when the DOM GPU process experimental feature flag is enabled for Safari tabs, it only
affects the web view used for rendering the main page content; importantly, this related web view
does not have DOM GPUP enabled.

When subsequently loading the web archive data via this reader web view, we end up *disabling* GPUP
for DOM rendering in the original tab's web process, due to the following code:

```
bool usingGPUProcessForDOMRendering = m_shouldRenderDOMInGPUProcess && DrawingArea::supportsGPUProcessRendering(m_drawingAreaType);
WebProcess::singleton().setUseGPUProcessForDOMRendering(usingGPUProcessForDOMRendering);
```

The current implementation of GPUP for DOM rendering doesn't handle on-the-fly GPUP disablement —
and in fact, in the case where IOKit has already been blocked in the web process, it's impossible to
disable GPUP at all once a page has been created with all the relevant GPUP flags enabled.

As such, we mitigate this by simply forcing DOM GPUP to be enabled (regardless of preferences state)
for a web view, if its related web view already has DOM GPUP enabled. Once DOM GPUP is enabled by
default, this won't be an issue anyway, since all web views will be created with consistent feature
flag statuses.

Test: GPUProcess.GPUProcessForDOMRenderingCarriesOverFromRelatedPage

* Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::useGPUProcessForDOMRenderingEnabled const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:
(-[NSUserDefaults swizzled_objectForKey:]):
(TestWebKitAPI::EnableUISideCompositingScope::EnableUISideCompositingScope):
(TestWebKitAPI::EnableUISideCompositingScope::~EnableUISideCompositingScope):

Add a new RAII helper class to temporarily swizzle out `-objectForKey:`, in order to forcibly enable
UI-side compositing for this test, as it's necessary to exercise the bug fix. Note that I'm using
swizzling here to avoid also enabling UI-side compositing for downstream API tests, even if the test
crashes or times out.

(TestWebKitAPI::TEST):
(convertToCGImage): Deleted.
(getPixelIndex): Deleted.
(TEST): Deleted.
(runMemoryPressureExitTest): Deleted.
(waitUntilCaptureState): Deleted.

Canonical link: https://commits.webkit.org/262296@main
@webkit-commit-queue
Copy link
Collaborator

Committed 262296@main (e74572e): https://commits.webkit.org/262296@main

Reviewed commits have been landed. Closing PR #12130 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit e74572e into WebKit:main Mar 29, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Portability improvements and other general platform improvements not driven directly by site bugs.
Projects
None yet
4 participants