Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Issue 2633253002: Split content script injections into multiple tasks (Closed)

Created:
3 years, 11 months ago by Kunihiko Sakamoto
Modified:
3 years, 8 months ago
CC:
blink-reviews, blink-reviews-api_chromium.org, chromium-apps-reviews_chromium.org, chromium-reviews, creis+watch_chromium.org, darin-cc_chromium.org, dglazkov+blink, extensions-reviews_chromium.org, jam, kinuko+watch, mlamouri+watch-content_chromium.org, nasko+codewatch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Split content script injections into multiple tasks Currently, content scripts for all extensions are injected in single task, causing a big jank on main thread. This patch changes document_end and document_idle content scripts to run in separate tasks asynchronously. The window.onload event is blocked until all document_end scripts are injected. This new behavior is protected by a feature switch, disabled by default. To enable asynchronous execution, this CL adds a option parameter to WebLocalFrame::requestExecuteScriptInIsolatedWorld(). Inside Blink, it uses SuspendableScriptExecutor's ability to delay execution. So async script executions are posted as timer tasks. To test the new behavior, browser tests in content_script_apitest.cc are parameterized so they run with and without the flag enabled. Also, some extensions for tests are switched from document_idle to document_end, since after this patch there's no reliable way to make sure that all document_idle scripts have finished. BUG=636655 Review-Url: https://codereview.chromium.org/2633253002 Cr-Commit-Position: refs/heads/master@{#457702} Committed: https://chromium.googlesource.com/chromium/src/+/cbf167aaccb8c6f17c305dffa76b6523776222bf

Patch Set 1 #

Total comments: 12

Patch Set 2 : comments addressed #

Patch Set 3 : rebase #

Patch Set 4 : Inject document_idle scripts before window.onload #

Total comments: 8

Patch Set 5 : comments addressed #

Patch Set 6 : rebase #

Total comments: 21

Patch Set 7 : comments addressed #

Patch Set 8 : rebase #

Total comments: 6

Patch Set 9 : comments addressed #

Total comments: 2

Patch Set 10 : comment addressed #

Patch Set 11 : rebase #

Total comments: 7

Patch Set 12 : comments addressed #

Unified diffs Side-by-side diffs Delta from patch set Stats (+310 lines, -55 lines) Patch
M chrome/browser/chrome_content_browser_client.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/extensions/content_script_apitest.cc View 1 2 3 4 5 6 7 8 15 chunks +57 lines, -23 lines 0 comments Download
M chrome/renderer/chrome_content_renderer_client.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M chrome/renderer/chrome_content_renderer_client.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +9 lines, -0 lines 0 comments Download
M chrome/renderer/extensions/chrome_extensions_renderer_client.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M chrome/renderer/extensions/chrome_extensions_renderer_client.cc View 1 2 3 1 chunk +5 lines, -0 lines 0 comments Download
M chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -1 line 0 comments Download
M chrome/test/data/extensions/platform_apps/web_view/content_script_whitelisted/main.js View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M content/public/renderer/content_renderer_client.h View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M content/renderer/render_frame_impl.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M content/renderer/render_frame_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +8 lines, -2 lines 0 comments Download
M extensions/common/feature_switch.h View 1 2 3 4 5 6 7 8 3 chunks +4 lines, -0 lines 0 comments Download
M extensions/common/feature_switch.cc View 1 2 3 4 5 6 7 8 9 10 5 chunks +17 lines, -1 line 0 comments Download
M extensions/common/switches.h View 1 chunk +1 line, -0 lines 0 comments Download
M extensions/common/switches.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M extensions/renderer/dispatcher.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M extensions/renderer/dispatcher.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +9 lines, -0 lines 0 comments Download
M extensions/renderer/extension_frame_helper.h View 1 2 3 3 chunks +9 lines, -0 lines 0 comments Download
M extensions/renderer/extension_frame_helper.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +11 lines, -0 lines 0 comments Download
M extensions/renderer/script_injection.h View 2 chunks +4 lines, -3 lines 0 comments Download
M extensions/renderer/script_injection.cc View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +49 lines, -8 lines 0 comments Download
M extensions/renderer/script_injection_manager.cc View 1 2 3 4 5 6 7 8 2 chunks +14 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/frame/LocalFrameClient.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/loader/EmptyClients.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/loader/FrameLoader.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +13 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/web/LocalFrameClientImpl.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/web/LocalFrameClientImpl.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +6 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/web/SuspendableScriptExecutor.h View 1 2 3 4 5 6 7 8 9 3 chunks +11 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp View 1 2 3 4 5 6 7 8 9 10 5 chunks +20 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/web/WebLocalFrameImpl.h View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/web/WebLocalFrameImpl.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +15 lines, -2 lines 0 comments Download
M third_party/WebKit/public/web/WebFrameClient.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/public/web/WebLocalFrame.h View 1 2 3 4 5 6 7 2 chunks +10 lines, -0 lines 0 comments Download
M third_party/WebKit/public/web/WebScriptExecutionCallback.h View 1 chunk +3 lines, -0 lines 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 3 4 5 6 7 8 9 10 1 chunk +10 lines, -0 lines 0 comments Download

Messages

Total messages: 118 (84 generated)
Kunihiko Sakamoto
devlin for extensions haraken for third_party/WebKit
3 years, 10 months ago (2017-02-13 05:37:30 UTC) #59
Devlin
One problem: We publicly document [1] that document_idle scripts will run no later than "immediately ...
3 years, 10 months ago (2017-02-13 23:13:10 UTC) #60
haraken
> One problem: > We publicly document [1] that document_idle scripts will run no later ...
3 years, 10 months ago (2017-02-14 00:16:30 UTC) #61
dcheng
On 2017/02/14 00:16:30, haraken wrote: > > One problem: > > We publicly document [1] ...
3 years, 10 months ago (2017-02-14 03:00:23 UTC) #62
haraken
On 2017/02/14 03:00:23, dcheng wrote: > On 2017/02/14 00:16:30, haraken wrote: > > > One ...
3 years, 10 months ago (2017-02-14 03:43:18 UTC) #63
dcheng
On 2017/02/14 03:43:18, haraken wrote: > On 2017/02/14 03:00:23, dcheng wrote: > > On 2017/02/14 ...
3 years, 10 months ago (2017-02-14 03:55:00 UTC) #64
haraken
On 2017/02/14 03:55:00, dcheng wrote: > On 2017/02/14 03:43:18, haraken wrote: > > On 2017/02/14 ...
3 years, 10 months ago (2017-02-14 03:56:40 UTC) #65
Kunihiko Sakamoto
Let me check if my understanding is correct... > We publicly document [1] that document_idle ...
3 years, 10 months ago (2017-02-14 09:07:54 UTC) #68
Devlin
On 2017/02/14 09:07:54, Kunihiko Sakamoto wrote: > Let me check if my understanding is correct... ...
3 years, 10 months ago (2017-02-14 16:03:51 UTC) #69
Kunihiko Sakamoto
PTAL Now document_idle script injections block window.onload. The only affected test was WebViewTests/WebViewTest.WhitelistedContentScript, which assumed ...
3 years, 10 months ago (2017-02-16 08:58:52 UTC) #77
Devlin
https://codereview.chromium.org/2633253002/diff/280001/chrome/renderer/chrome_content_renderer_client.cc File chrome/renderer/chrome_content_renderer_client.cc (right): https://codereview.chromium.org/2633253002/diff/280001/chrome/renderer/chrome_content_renderer_client.cc#newcode1406 chrome/renderer/chrome_content_renderer_client.cc:1406: // |render_frame| might be dead by now. Duplicate this ...
3 years, 10 months ago (2017-02-21 18:56:27 UTC) #81
Kunihiko Sakamoto
https://codereview.chromium.org/2633253002/diff/280001/chrome/renderer/chrome_content_renderer_client.cc File chrome/renderer/chrome_content_renderer_client.cc (right): https://codereview.chromium.org/2633253002/diff/280001/chrome/renderer/chrome_content_renderer_client.cc#newcode1406 chrome/renderer/chrome_content_renderer_client.cc:1406: // |render_frame| might be dead by now. On 2017/02/21 ...
3 years, 10 months ago (2017-02-23 09:49:01 UTC) #82
Kunihiko Sakamoto
Devlin - friendly ping :)
3 years, 9 months ago (2017-03-01 07:26:17 UTC) #87
Devlin
Sorry for the delay! A few small nits, but otherwise I think this looks pretty ...
3 years, 9 months ago (2017-03-02 02:33:17 UTC) #88
haraken
WebKit/ mostly looks good. https://codereview.chromium.org/2633253002/diff/320001/third_party/WebKit/Source/core/loader/FrameLoader.cpp File third_party/WebKit/Source/core/loader/FrameLoader.cpp (right): https://codereview.chromium.org/2633253002/diff/320001/third_party/WebKit/Source/core/loader/FrameLoader.cpp#newcode725 third_party/WebKit/Source/core/loader/FrameLoader.cpp:725: if (!m_frame->client()) m_frame->client() => client() ...
3 years, 9 months ago (2017-03-02 03:54:33 UTC) #89
Kunihiko Sakamoto
https://codereview.chromium.org/2633253002/diff/320001/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js File chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js (right): https://codereview.chromium.org/2633253002/diff/320001/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js#newcode47 chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js:47: onRequest.removeListener(listener); On 2017/03/02 02:33:17, Devlin wrote: > why this ...
3 years, 9 months ago (2017-03-06 09:11:06 UTC) #91
Devlin
https://codereview.chromium.org/2633253002/diff/320001/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js File chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js (right): https://codereview.chromium.org/2633253002/diff/320001/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js#newcode47 chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js:47: onRequest.removeListener(listener); On 2017/03/06 09:11:05, Kunihiko Sakamoto wrote: > On ...
3 years, 9 months ago (2017-03-10 03:18:45 UTC) #92
Kunihiko Sakamoto
https://codereview.chromium.org/2633253002/diff/320001/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js File chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js (right): https://codereview.chromium.org/2633253002/diff/320001/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js#newcode47 chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js:47: onRequest.removeListener(listener); On 2017/03/10 03:18:44, Devlin wrote: > On 2017/03/06 ...
3 years, 9 months ago (2017-03-10 07:07:28 UTC) #93
Devlin
Nice, lgtm! https://codereview.chromium.org/2633253002/diff/320001/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js File chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js (right): https://codereview.chromium.org/2633253002/diff/320001/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js#newcode47 chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js:47: onRequest.removeListener(listener); On 2017/03/10 07:07:28, Kunihiko Sakamoto wrote: ...
3 years, 9 months ago (2017-03-14 15:08:55 UTC) #94
haraken
LGTM https://codereview.chromium.org/2633253002/diff/400001/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp File third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp (right): https://codereview.chromium.org/2633253002/diff/400001/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp#newcode211 third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp:211: m_blockingOnload = true; Can we replace the boolean ...
3 years, 9 months ago (2017-03-14 15:18:40 UTC) #95
Kunihiko Sakamoto
+jochen PTAL for chrome/renderer/chrome_content_renderer_client.{h,cc} +kinuko PTAL for content/ +isherman PTAL for histograms.xml Thanks! https://codereview.chromium.org/2633253002/diff/400001/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp File ...
3 years, 9 months ago (2017-03-15 07:53:12 UTC) #99
Ilya Sherman
Metrics LGTM, with a question: https://codereview.chromium.org/2633253002/diff/440001/tools/metrics/histograms/histograms.xml File tools/metrics/histograms/histograms.xml (right): https://codereview.chromium.org/2633253002/diff/440001/tools/metrics/histograms/histograms.xml#newcode18417 tools/metrics/histograms/histograms.xml:18417: + Unlike Extensions.InjectScriptTime, this ...
3 years, 9 months ago (2017-03-15 08:18:07 UTC) #100
kinuko
https://codereview.chromium.org/2633253002/diff/440001/content/renderer/render_frame_impl.cc File content/renderer/render_frame_impl.cc (right): https://codereview.chromium.org/2633253002/diff/440001/content/renderer/render_frame_impl.cc#newcode3916 content/renderer/render_frame_impl.cc:3916: return; How could it be null right after this ...
3 years, 9 months ago (2017-03-15 12:13:29 UTC) #103
jochen (gone - plz use gerrit)
chrome/renderer/chrome_content_renderer_client.{h,cc} lgtm
3 years, 9 months ago (2017-03-15 15:52:03 UTC) #104
Kunihiko Sakamoto
https://codereview.chromium.org/2633253002/diff/440001/content/renderer/render_frame_impl.cc File content/renderer/render_frame_impl.cc (right): https://codereview.chromium.org/2633253002/diff/440001/content/renderer/render_frame_impl.cc#newcode3916 content/renderer/render_frame_impl.cc:3916: return; On 2017/03/15 12:13:28, kinuko wrote: > How could ...
3 years, 9 months ago (2017-03-16 07:39:03 UTC) #105
kinuko
content lgtm
3 years, 9 months ago (2017-03-16 09:54:38 UTC) #106
kinuko
content lgtm
3 years, 9 months ago (2017-03-16 09:54:41 UTC) #107
Devlin
https://codereview.chromium.org/2633253002/diff/440001/tools/metrics/histograms/histograms.xml File tools/metrics/histograms/histograms.xml (right): https://codereview.chromium.org/2633253002/diff/440001/tools/metrics/histograms/histograms.xml#newcode18417 tools/metrics/histograms/histograms.xml:18417: + Unlike Extensions.InjectScriptTime, this includes execution time of On ...
3 years, 9 months ago (2017-03-16 14:56:17 UTC) #108
Kunihiko Sakamoto
On 2017/03/16 14:56:17, Devlin wrote: > https://codereview.chromium.org/2633253002/diff/440001/tools/metrics/histograms/histograms.xml > File tools/metrics/histograms/histograms.xml (right): > > https://codereview.chromium.org/2633253002/diff/440001/tools/metrics/histograms/histograms.xml#newcode18417 > ...
3 years, 9 months ago (2017-03-17 05:01:51 UTC) #109
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2633253002/460001
3 years, 9 months ago (2017-03-17 05:02:38 UTC) #112
commit-bot: I haz the power
Committed patchset #12 (id:460001) as https://chromium.googlesource.com/chromium/src/+/cbf167aaccb8c6f17c305dffa76b6523776222bf
3 years, 9 months ago (2017-03-17 06:46:59 UTC) #115
haraken
Have we observed any improvement in UMA numbers?
3 years, 9 months ago (2017-03-24 09:53:29 UTC) #116
kouhei (in TOK)
On 2017/03/24 09:53:29, haraken wrote: > Have we observed any improvement in UMA numbers? We ...
3 years, 9 months ago (2017-03-24 10:30:07 UTC) #117
Kunihiko Sakamoto
3 years, 8 months ago (2017-03-27 07:26:22 UTC) #118
Message was sent while issue was closed.
On 2017/03/24 10:30:07, kouhei wrote:
> On 2017/03/24 09:53:29, haraken wrote:
> > Have we observed any improvement in UMA numbers?
> We are trying to assess that via Finch and currently Finch launch process
under
> way

Yes this is the launch bug: http://crbug.com/705400

Powered by Google App Engine
This is Rietveld 408576698