Bug 218924

Summary: [GPUProcess] Add basic GPUProcess crash handling for canvas
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, sabouhallawa, simon.fraser, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=219007
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2020-11-13 15:13:27 PST
Add basic GPUProcess crash handling for canvas.
Comment 1 Chris Dumez 2020-11-13 15:22:46 PST
Created attachment 414098 [details]
Patch
Comment 2 Simon Fraser (smfr) 2020-11-13 15:59:44 PST
Comment on attachment 414098 [details]
Patch

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

> Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h:83
> +    float resolutionScale() const override { return m_resolutionScale; }

final?

> Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:66
> +    // Register itself as a MessageReceiver in the GPUProcessConnection.

Comment doesn't add anything.

> Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:70
> +    IPC::MessageReceiverMap& messageReceiverMap = connection.messageReceiverMap();

auto?

> Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:74
> +    send(Messages::GPUConnectionToWebProcess::CreateRenderingBackend(m_renderingBackendIdentifier), 0);

Comment doesn't add anything.

> Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:101
> +    connectToGPUProcess();
> +
> +    for (auto& pair : m_remoteResourceCacheProxy.imageBuffers()) {
> +        if (auto& baseImageBuffer = pair.value) {
> +            if (is<AcceleratedRemoteImageBufferProxy>(*baseImageBuffer))
> +                recreateImageBuffer(*this, downcast<AcceleratedRemoteImageBufferProxy>(*baseImageBuffer), pair.key, m_renderingBackendIdentifier);
> +            else
> +                recreateImageBuffer(*this, downcast<UnacceleratedRemoteImageBufferProxy>(*baseImageBuffer), pair.key, m_renderingBackendIdentifier);
> +        }
> +    }

It's weird to see this code in a "didClose" function. It would be nicer to move this to a "reestablishGPUConnection" function.
Comment 3 Chris Dumez 2020-11-13 16:14:15 PST
Created attachment 414103 [details]
Patch
Comment 4 EWS 2020-11-13 18:11:53 PST
Committed r269809: <https://trac.webkit.org/changeset/269809>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 414103 [details].
Comment 5 Radar WebKit Bug Importer 2020-11-13 18:12:20 PST
<rdar://problem/71392812>
Comment 6 Darin Adler 2020-11-15 13:17:09 PST
Comment on attachment 414103 [details]
Patch

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

> Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:416
> +        RetainPtr<CGContextRef> context = CGBitmapContextCreate(rgba, viewWidthInPixels, viewHeightInPixels, 8, 4 * viewWidthInPixels, colorSpace.get(), kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);

Missing adoptCF here, so this bitmap context will leak.
Comment 7 Chris Dumez 2020-11-16 08:54:54 PST
(In reply to Darin Adler from comment #6)
> Comment on attachment 414103 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=414103&action=review
> 
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:416
> > +        RetainPtr<CGContextRef> context = CGBitmapContextCreate(rgba, viewWidthInPixels, viewHeightInPixels, 8, 4 * viewWidthInPixels, colorSpace.get(), kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
> 
> Missing adoptCF here, so this bitmap context will leak.

I had copied from an existing screenshot tests. Will fix existing tests and new tests via https://bugs.webkit.org/show_bug.cgi?id=218988. Thanks.