New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 642380 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Blocking:
issue 528837
issue 636655



Sign in to add a comment

Make extension port creation asynchronous

Project Member Reported by rdevlin....@chromium.org, Aug 30 2016

Issue description

Currently, extension port creation uses a sync IPC.  This is terrible for a few reasons:
1. Sync IPCs are always terrible
2. This can happen on the critical path to document parsing, e.g. in a content script that executes at document_start
3. It can be slow enough to cause a renderer hang (issue 528837)
4. Sync IPCs are always terrible

We should asyncify this.  It'll be a bit tricky at parts, but I think it can be done without too much pain.
 
Project Member

Comment 2 by bugdroid1@chromium.org, Sep 10 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dbbe69e7a03b50940d5b7e615c04de531511cac3

commit dbbe69e7a03b50940d5b7e615c04de531511cac3
Author: rdevlin.cronin <rdevlin.cronin@chromium.org>
Date: Sat Sep 10 00:48:02 2016

[Extensions] Begin making Extension port initialization asynchronous

Currently, extension port initialization requires a synchronous IPC to
the browser. This is bad, as this can happen during very performance-
sensitive times, such as a content script running at document_start.
Make the port initialization process asynchronous.

To do this, introduce the concept of local vs global ids. A local id is
the id of the port in the javascript context, and the global id is used
by the core extension system. The local id is set synchronously; the
global is set asynchronously. This change also allows us to determine
more quickly whether or not a port exists in a given context.

Because ports are supposed to be able to be used synchronously, also
instrument message caching that will wait until the port is fully
initialized before dispatching any messages.

To begin, this change only modifies the behavior for extension message
ports constructed through runtime.connect(). Ports constructed through
tabs.connect() or runtime.connectNative() will be addressed in
subsequent patches.

This also required updated a number of extensions tests which made
incorrect assumptions about the order of APIs finishing (in particular,
that a port's message would be sent prior to a script executing). This
was never in any way guaranteed.

Drive-by change: Make the extension not having connectNative
permissions in trying to connect to a native app a hard failure.

BUG= 642380 

Review-Url: https://codereview.chromium.org/2300453002
Cr-Commit-Position: refs/heads/master@{#417784}

[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/browser/renderer_host/chrome_extension_message_filter.cc
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/browser/renderer_host/chrome_extension_message_filter.h
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/renderer/BUILD.gn
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/renderer/chrome_mock_render_thread.cc
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/renderer/chrome_mock_render_thread.h
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc
[delete] https://crrev.com/a6c565ab62ce68c7c2ed27ecd03f76b917009756/chrome/renderer/extensions/tabs_custom_bindings.cc
[delete] https://crrev.com/a6c565ab62ce68c7c2ed27ecd03f76b917009756/chrome/renderer/extensions/tabs_custom_bindings.h
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/renderer/resources/extensions/tabs_custom_bindings.js
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/test/data/extensions/api_test/executescript/in_frame/test.js
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/chrome/test/data/extensions/api_test/executescript/removed_frames/test.js
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/common/extension_messages.h
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/BUILD.gn
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/extension_frame_helper.cc
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/extension_frame_helper.h
[add] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/extension_port.cc
[add] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/extension_port.h
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/messaging_bindings.cc
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/messaging_bindings.h
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/resources/messaging.js
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/resources/runtime_custom_bindings.js
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/runtime_custom_bindings.cc
[modify] https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3/extensions/renderer/runtime_custom_bindings.h

Status: Fixed (was: Assigned)

Sign in to add a comment