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>
Created attachment 71931 [details] Post pending messages to the Injected Bundle in WebContext::processDidFinishLaunching
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.
(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 on attachment 71931 [details] Post pending messages to the Injected Bundle in WebContext::processDidFinishLaunching Committed in r70568 http://trac.webkit.org/changeset/70568