Bug 48367

Summary: Post any pending messages to the Injected Bundle in WebContext::processDidFinishLaunching instead of in WebContext::ensureWebProcess
Product: WebKit Reporter: Jessie Berlin <jberlin>
Component: WebKit2Assignee: Jessie Berlin <jberlin>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, jberlin, sam
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Post pending messages to the Injected Bundle in WebContext::processDidFinishLaunching none

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