RESOLVED CONFIGURATION CHANGED224155
[GPUP] Purge renderer resources after 2D canvas and media features become inactive
https://bugs.webkit.org/show_bug.cgi?id=224155
Summary [GPUP] Purge renderer resources after 2D canvas and media features become ina...
Peng Liu
Reported 2021-04-03 11:35:14 PDT
[GPUP] Purge renderer resources after 2D canvas and media features become inactive
Attachments
WIP patch (2.60 KB, patch)
2021-04-03 11:39 PDT, Peng Liu
no flags
WIP patch (3.83 KB, patch)
2021-04-03 11:46 PDT, Peng Liu
no flags
Patch (5.79 KB, patch)
2021-04-05 11:53 PDT, Peng Liu
no flags
Patch (6.38 KB, patch)
2021-04-05 12:54 PDT, Peng Liu
no flags
Patch, not tested (3.66 KB, patch)
2021-04-07 03:30 PDT, Kimmo Kinnunen
no flags
Patch, not tested (3.66 KB, patch)
2021-04-07 03:30 PDT, Kimmo Kinnunen
ews-feeder: commit-queue-
Patch, not tested (3.67 KB, patch)
2021-04-07 04:31 PDT, Kimmo Kinnunen
no flags
Peng Liu
Comment 1 2021-04-03 11:39:37 PDT
Created attachment 425102 [details] WIP patch
Peng Liu
Comment 2 2021-04-03 11:46:53 PDT
Created attachment 425103 [details] WIP patch
Radar WebKit Bug Importer
Comment 3 2021-04-04 22:18:25 PDT
Jon Lee
Comment 4 2021-04-05 10:48:04 PDT
Peng Liu
Comment 5 2021-04-05 11:53:47 PDT
Simon Fraser (smfr)
Comment 6 2021-04-05 12:00:02 PDT
Comment on attachment 425180 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425180&action=review > Source/WebKit/GPUProcess/graphics/ScopedRenderingResourcesRequestCocoa.mm:73 > + [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidEnterBackgroundNotification object:nil userInfo:nil]; Rather than softlink UIKIt, you can use use the NSString* version of these: @"UIApplicationDidEnterBackgroundNotification" (please check the actual string). > Source/WebKit/GPUProcess/ios/GPUProcessIOS.mm:54 > + int token; > + notify_register_dispatch("org.WebKit.GPUProcessPurgeUnusedResources", &token, dispatch_get_main_queue(), ^(int) { > + [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidEnterBackgroundNotification object:nil userInfo:nil]; > + } > + ); > + > + [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidFinishLaunchingNotification object:nil userInfo:nil]; Do we want this? Should we instead respond to "org.WebKit.lowMemory" which the tests already send?
Peng Liu
Comment 7 2021-04-05 12:29:06 PDT
Comment on attachment 425180 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425180&action=review >> Source/WebKit/GPUProcess/ios/GPUProcessIOS.mm:54 >> + [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidFinishLaunchingNotification object:nil userInfo:nil]; > > Do we want this? Should we instead respond to "org.WebKit.lowMemory" which the tests already send? I suppose you referred to the line of `notify_register_dispatch`? Yes, sounds a good idea to do it in response of "org.WebKit.lowMemory".
Peng Liu
Comment 8 2021-04-05 12:54:24 PDT
Peng Liu
Comment 9 2021-04-05 13:06:06 PDT
Comment on attachment 425180 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425180&action=review >> Source/WebKit/GPUProcess/graphics/ScopedRenderingResourcesRequestCocoa.mm:73 >> + [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidEnterBackgroundNotification object:nil userInfo:nil]; > > Rather than softlink UIKIt, you can use use the NSString* version of these: @"UIApplicationDidEnterBackgroundNotification" (please check the actual string). Fixed.
Kimmo Kinnunen
Comment 10 2021-04-05 23:03:18 PDT
Comment on attachment 425191 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425191&action=review I think there's couple of checks that still need taken care of? Ping me offline unless you know the cases and have taken care of them. > Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm:127 > + [[NSNotificationCenter defaultCenter] postNotificationName:@"UIApplicationDidEnterBackgroundNotification" object:nil userInfo:nil]; This causes wrong counts, e.g. the receivers think the app is in the background even though it might be in the foreground. How/where do we undo the action done here? > Source/WebKit/GPUProcess/graphics/ScopedRenderingResourcesRequest.h:76 > + if (!s_requests) I don't think this sort of thing is thread-safe? > Source/WebKit/GPUProcess/graphics/ScopedRenderingResourcesRequestCocoa.mm:72 > + [[NSNotificationCenter defaultCenter] postNotificationName:@"UIApplicationDidEnterBackgroundNotification" object:nil userInfo:nil]; I wonder if nsnotificationchenter posting is thread safe?
Peng Liu
Comment 11 2021-04-06 12:08:46 PDT
Some Core Animation states need to be taken care of properly. Over to Kimmo. :-)
Kimmo Kinnunen
Comment 12 2021-04-07 03:30:02 PDT
Created attachment 425375 [details] Patch, not tested
Kimmo Kinnunen
Comment 13 2021-04-07 03:30:58 PDT
Created attachment 425376 [details] Patch, not tested
Kimmo Kinnunen
Comment 14 2021-04-07 04:31:34 PDT
Created attachment 425380 [details] Patch, not tested
Darin Adler
Comment 15 2021-04-17 21:38:47 PDT
Do you want someone to review your untested patch? Normally we’d want to review it after it’s tested.
Chris Dumez
Comment 16 2021-04-17 22:19:18 PDT
(In reply to Darin Adler from comment #15) > Do you want someone to review your untested patch? Normally we’d want to > review it after it’s tested. I think the decision during the last GPUProcess sync-up was to A/B test this patch after I landed the GPUProcess idle exit change. My patch has landed now. Kimmo, do you need help scheduling the A/B test?
Note You need to log in before you can comment on or make changes to this bug.