Bug 211160

Summary: REGRESSION (r260407): Over-release of NSGraphicsContext in WebKit::convertPlatformImageToBitmap()
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebKit2Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, nmouchtaris, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=210814
https://bugs.webkit.org/show_bug.cgi?id=211274
https://bugs.webkit.org/show_bug.cgi?id=211660
Bug Depends on: 208891    
Bug Blocks:    
Attachments:
Description Flags
Patch v1
darin: review+, ddkilzer: commit-queue-
Patch for landing none

David Kilzer (:ddkilzer)
Reported 2020-04-28 19:33:24 PDT
Over-release of NSGraphicsContext in WebKit::convertPlatformImageToBitmap(). Occurred in r260407 for Bug 208891: auto savedContext = adoptNS([NSGraphicsContext currentContext]);
Attachments
Patch v1 (1.83 KB, patch)
2020-04-28 19:34 PDT, David Kilzer (:ddkilzer)
darin: review+
ddkilzer: commit-queue-
Patch for landing (1.79 KB, patch)
2020-04-28 20:01 PDT, David Kilzer (:ddkilzer)
no flags
David Kilzer (:ddkilzer)
Comment 1 2020-04-28 19:34:06 PDT
Created attachment 397917 [details] Patch v1
David Kilzer (:ddkilzer)
Comment 2 2020-04-28 19:43:35 PDT
Comment on attachment 397917 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=397917&action=review > Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:408 > - auto savedContext = adoptNS([NSGraphicsContext currentContext]); > + RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext]; Do we have an RAII object to save NSGraphicsContext.currentContext? Seems like it might be useful.
David Kilzer (:ddkilzer)
Comment 3 2020-04-28 19:51:01 PDT
Comment on attachment 397917 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=397917&action=review >> Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:408 >> + RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext]; > > Do we have an RAII object to save NSGraphicsContext.currentContext? Seems like it might be useful. Looks like we have this in WebCore, but it's all CG-based: ALLOW_DEPRECATED_DECLARATIONS_BEGIN CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; ALLOW_DEPRECATED_DECLARATIONS_END CGContextStateSaver stateSaver(cgContext); Via drawCellFocusRingWithFrameAtTime() in Source/WebCore/platform/mac/ThemeMac.mm.
Darin Adler
Comment 4 2020-04-28 19:54:11 PDT
Comment on attachment 397917 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=397917&action=review >>> Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:408 >>> + RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext]; >> >> Do we have an RAII object to save NSGraphicsContext.currentContext? Seems like it might be useful. > > Looks like we have this in WebCore, but it's all CG-based: > > ALLOW_DEPRECATED_DECLARATIONS_BEGIN > CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; > ALLOW_DEPRECATED_DECLARATIONS_END > > CGContextStateSaver stateSaver(cgContext); > > Via drawCellFocusRingWithFrameAtTime() in Source/WebCore/platform/mac/ThemeMac.mm. Instead of writing out RetainPtr, I suggest you just change the adoptNS() to retainPtr().
David Kilzer (:ddkilzer)
Comment 5 2020-04-28 19:57:48 PDT
Comment on attachment 397917 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=397917&action=review >>>> Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:408 >>>> + RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext]; >>> >>> Do we have an RAII object to save NSGraphicsContext.currentContext? Seems like it might be useful. >> >> Looks like we have this in WebCore, but it's all CG-based: >> >> ALLOW_DEPRECATED_DECLARATIONS_BEGIN >> CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; >> ALLOW_DEPRECATED_DECLARATIONS_END >> >> CGContextStateSaver stateSaver(cgContext); >> >> Via drawCellFocusRingWithFrameAtTime() in Source/WebCore/platform/mac/ThemeMac.mm. > > Instead of writing out RetainPtr, I suggest you just change the adoptNS() to retainPtr(). Thanks, I had forgotten about that helper.
David Kilzer (:ddkilzer)
Comment 6 2020-04-28 20:01:12 PDT
Created attachment 397918 [details] Patch for landing
Tim Horton
Comment 7 2020-04-28 20:11:30 PDT
I think Darin might have been referring to LocalCurrentGraphicsContext?
David Kilzer (:ddkilzer)
Comment 8 2020-04-28 21:09:25 PDT
Comment on attachment 397918 [details] Patch for landing Setting cq+ with win bot orange as this code isn't used on Windows.
EWS
Comment 9 2020-04-28 21:26:17 PDT
Committed r260864: <https://trac.webkit.org/changeset/260864> All reviewed patches have been landed. Closing bug and clearing flags on attachment 397918 [details].
Radar WebKit Bug Importer
Comment 10 2020-04-28 21:27:15 PDT
Darin Adler
Comment 11 2020-04-29 11:39:54 PDT
(In reply to Tim Horton from comment #7) > I think Darin might have been referring to LocalCurrentGraphicsContext? It does seem like LocalCurrentGraphicsContext would be usable here with a tiny bit of refactoring.
Note You need to log in before you can comment on or make changes to this bug.