WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
105674
Ensure autorelease pool exists when calling WKNSProcessInfoProcessAssertionWithTypes on Mac
https://bugs.webkit.org/show_bug.cgi?id=105674
Summary
Ensure autorelease pool exists when calling WKNSProcessInfoProcessAssertionWi...
Kiran Muppala
Reported
2012-12-21 19:19:31 PST
WebKit2 child processes on Mac call the WebKitSystemInterface function WKNSProcessInfoProcessAssertionWithTypes, to take a process visible assertion during initialization, which for non XPC Service processes such as NetworkProcess, PluginProcess happens prior to the main runloop being started and hence a autorelease pool being established. Thus, the autoreleased assertion object returned by the first call is leaked and hence the process does not subsequently go to sleep even after releasing the assertion. To ensure the assertion object is correctly released, the call to the above function should be enclosed by a @autoreleasepool block.
Attachments
Patch
(1.90 KB, patch)
2012-12-21 19:25 PST
,
Kiran Muppala
no flags
Details
Formatted Diff
Diff
Patch
(5.65 KB, patch)
2013-01-02 15:39 PST
,
Kiran Muppala
no flags
Details
Formatted Diff
Diff
Patch
(4.41 KB, patch)
2013-01-02 16:37 PST
,
Kiran Muppala
no flags
Details
Formatted Diff
Diff
Patch
(4.38 KB, patch)
2013-01-02 16:44 PST
,
Kiran Muppala
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Kiran Muppala
Comment 1
2012-12-21 19:19:43 PST
<
rdar://problem/12928750
>
Kiran Muppala
Comment 2
2012-12-21 19:25:59 PST
Created
attachment 180585
[details]
Patch
Sam Weinig
Comment 3
2012-12-22 18:19:34 PST
I don't see how this is being called before initialization. Can you point to where that is being done?
Kiran Muppala
Comment 4
2012-12-22 19:22:16 PST
(In reply to
comment #3
)
> I don't see how this is being called before initialization. Can you point to where that is being done?
Thanks for taking a look at this patch. The very first call to ChildProcess::setApplicationIsOccluded() happens from ChildProcess::platformInitialize(). Which in turn happens before the runloop starts. For example, here is the bottom portion of NetworkProcessMain() from NetworkProcessMainMac.mm InitWebCoreSystemInterface(); JSC::initializeThreading(); WTF::initializeMainThread(); RunLoop::initializeMainRunLoop(); // Initialize the network process connection. NetworkProcess::shared().initialize(CoreIPC::Connection::Identifier(serverPort), RunLoop::main()); [NSApplication sharedApplication]; RunLoop::run(); return 0; } The call to NetworkProcess::shared() happens prior to RunLoop::run(). The former call results in ChildProcess object being constructed, which in turn calls ChildProcess::platformInitialize(). WebProcess doesn't run into this because xpc_main itself starts the runloop. On the flip side, WebProcess also doesn't take an assertion until the bootstrap message is received. It is preferable to take the assertion prior to the runloop starting so that the process doesn't need a subsequent message to keep it from being suppressed.
Sam Weinig
Comment 5
2012-12-22 19:38:42 PST
Ah! In that case, I think it would better to add the @autoreleasepool to NetworkProcessMain. We already have this in WebProcessInitialization.mm. Why do we wait for the bootstrap message to do this if it is preferable to do it earlier?
Kiran Muppala
Comment 6
2012-12-22 20:47:19 PST
(In reply to
comment #5
)
> Ah! In that case, I think it would better to add the @autoreleasepool to NetworkProcessMain. We already have this in WebProcessInitialization.mm.
I would have to do that for PluginProcess and SharedWorkerProcess too. Also, it won't be easy to tell why the pool is there. In WebProcessInitialization.mm the call to [NSString stringWithFormat:] points to the reason immediately. May be you already considered these. Would you still prefer the pool be moved to the main routine of the respective processes? I could also push CoreFoundation folks to provide a non autorelease version of the assertion, or even a plain old c function, just to throw another option.
> > Why do we wait for the bootstrap message to do this if it is preferable to do it earlier?
This is purely a limitation introduced by the assertion method being SPI and not API. WebProcessServiceForWebKitDevelopment does not load WKSI until the bootstrap message is received. But, to receive the message xpc_main() has to be called in the first place. WebProcessService doesn't have this problem, so I could take an assertion there before xpc_main(). But, since it is not critical do to that, the process will be un suppressed by a incoming xpc message, both services take an assertion when handling the bootstrap message.
Kiran Muppala
Comment 7
2012-12-22 21:45:11 PST
(In reply to
comment #5
)
> Ah! In that case, I think it would better to add the @autoreleasepool to NetworkProcessMain. We already have this in WebProcessInitialization.mm. >
Oh, I thought of another option. How about I move the @autoreleasepool to ChildProcess::platformInitialize? That way the cost is only incurred once, and I don't have to paste it in three different locations.
Sam Weinig
Comment 8
2012-12-23 07:08:19 PST
(In reply to
comment #7
)
> (In reply to
comment #5
) > > Ah! In that case, I think it would better to add the @autoreleasepool to NetworkProcessMain. We already have this in WebProcessInitialization.mm. > > > Oh, I thought of another option. How about I move the @autoreleasepool to ChildProcess::platformInitialize? That way the cost is only incurred once, and I don't have to paste it in three different locations.
I think doing it in NetworkProcessMain (and in the other two as well) is the best option.
Kiran Muppala
Comment 9
2012-12-23 16:38:12 PST
(In reply to
comment #8
)
> (In reply to
comment #7
) > > (In reply to
comment #5
) > > > Ah! In that case, I think it would better to add the @autoreleasepool to NetworkProcessMain. We already have this in WebProcessInitialization.mm. > > > > > Oh, I thought of another option. How about I move the @autoreleasepool to ChildProcess::platformInitialize? That way the cost is only incurred once, and I don't have to paste it in three different locations. > > I think doing it in NetworkProcessMain (and in the other two as well) is the best option.
Ok, will upload a updated patch. Thanks.
Kiran Muppala
Comment 10
2013-01-02 15:39:31 PST
Created
attachment 181088
[details]
Patch
Kiran Muppala
Comment 11
2013-01-02 15:40:47 PST
(In reply to
comment #10
)
> Created an attachment (id=181088) [details] > Patch
Moved @autoreleasepool block to main process initialization method of NetworkProcess, PluginProcess and SharedWorkerProcess.
Kiran Muppala
Comment 12
2013-01-02 16:37:00 PST
Created
attachment 181106
[details]
Patch
Kiran Muppala
Comment 13
2013-01-02 16:39:26 PST
(In reply to
comment #12
)
> Created an attachment (id=181106) [details] > Patch
NetworkProcess initialization code was moved to a separate method with an autorelease pool by
https://bugs.webkit.org/show_bug.cgi?id=105946
, hence removed changes to NetworkProcess in this patch, which also fixed the merge conflict with previous patch.
Kiran Muppala
Comment 14
2013-01-02 16:44:45 PST
Created
attachment 181108
[details]
Patch
Kiran Muppala
Comment 15
2013-01-02 16:45:10 PST
(In reply to
comment #14
)
> Created an attachment (id=181108) [details] > Patch
Removed unnecessary white space. No functional change.
WebKit Review Bot
Comment 16
2013-01-03 15:21:00 PST
Comment on
attachment 181108
[details]
Patch Clearing flags on attachment: 181108 Committed
r138752
: <
http://trac.webkit.org/changeset/138752
>
WebKit Review Bot
Comment 17
2013-01-03 15:21:04 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug