Bug 48367 - Post any pending messages to the Injected Bundle in WebContext::processDidFinishLaunching instead of in WebContext::ensureWebProcess
Summary: Post any pending messages to the Injected Bundle in WebContext::processDidFin...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Jessie Berlin
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2010-10-26 12:49 PDT by Jessie Berlin
Modified: 2010-10-26 13:53 PDT (History)
3 users (show)

See Also:


Attachments
Post pending messages to the Injected Bundle in WebContext::processDidFinishLaunching (2.38 KB, patch)
2010-10-26 12:53 PDT, Jessie Berlin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jessie Berlin 2010-10-26 12:49:14 PDT
We currently post those pending Injected Bundle messages in WebContext::ensureWebProcess.

However it is possible for messages to be sent to WebContext::postMessageToInjectedBundle in between the call to ensureWebProcess and the asychronous callback that results in WebProcessProxy::didFinishLaunching being called.

During that time, the WebProcessProxy is invalid so messages in WebContext::postMessageToInjectedBundle get added to the m_pendingMessagesToPostToInjectedBundle and will never actually be sent.

Instead, we should wait for the process to finish launching before we post the pending messages to the Injected Bundle (in WebContext::processDidFinishLaunching).

<rdar://problem/8595623>
Comment 1 Jessie Berlin 2010-10-26 12:53:15 PDT
Created attachment 71931 [details]
Post pending messages to the Injected Bundle in WebContext::processDidFinishLaunching
Comment 2 Darin Adler 2010-10-26 13:30:42 PDT
Comment on attachment 71931 [details]
Post pending messages to the Injected Bundle in WebContext::processDidFinishLaunching

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

> WebKit2/UIProcess/WebContext.cpp:192
> +        pair<String, RefPtr<APIObject> >* message = &m_pendingMessagesToPostToInjectedBundle[i];
> +        m_process->send(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(message->first, WebContextUserMessageEncoder(message->second.get())));

You are just moving this code, and didn’t write it. I would have used a reference instead of a pointer here.
Comment 3 Jessie Berlin 2010-10-26 13:40:09 PDT
(In reply to comment #2)
> (From update of attachment 71931 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=71931&action=review
> 
> > WebKit2/UIProcess/WebContext.cpp:192
> > +        pair<String, RefPtr<APIObject> >* message = &m_pendingMessagesToPostToInjectedBundle[i];
> > +        m_process->send(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(message->first, WebContextUserMessageEncoder(message->second.get())));
> 
> You are just moving this code, and didn’t write it. I would have used a reference instead of a pointer here.

Actually, I believe that was me in http://trac.webkit.org/changeset/67593.

Changed to be:

pair<String, RefPtr<APIObject> >& message = m_pendingMessagesToPostToInjectedBundle[i];
m_process->send(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(message.first, WebContextUserMessageEncoder(message.second.get())));

Thanks for the review!
Comment 4 Jessie Berlin 2010-10-26 13:52:59 PDT
Comment on attachment 71931 [details]
Post pending messages to the Injected Bundle in WebContext::processDidFinishLaunching

Committed in r70568
http://trac.webkit.org/changeset/70568