Restricted nested message loop

41 views
Skip to first unread message

Kentaro Hara

unread,
Jun 13, 2016, 1:36:09 AM6/13/16
to platform-architecture-dev
Hi

While brainstorming strategies for isolating performance of third-party iframes, I started thinking about the idea of running main frame's task in a nested message loop of third-party iframes. Needless to say, we cannot simply use a normal nested message loop for this purpose because it is dangerous. To mitigate the security risk, I'm now thinking about defining safe points and letting the user agent start the nested message loop at the safe points.

I'm only 70% sure if the idea is feasible (or sane) but tried to write a document. Any input is welcome :)


--
Kentaro Hara, Tokyo, Japan

Kentaro Hara

unread,
Jun 15, 2016, 7:25:47 AM6/15/16
to platform-architecture-dev, Takashi Sakamoto
tasak@ and I collected some data to understand how much third-party scripts are disturbing the main frame.


Each column lists execution times of cross-origin scripts that took >16 ms. We can observe many >100 ms scripts running even on desktops. Some scripts are taking >500 ms. The main frame is blocked during the script execution :/

(Note that some of the websites return different pages for Linux desktop and Nexus4.)



Elliott Sprehn

unread,
Jun 15, 2016, 7:31:04 AM6/15/16
to Kentaro Hara, platform-architecture-dev, Takashi Sakamoto

Do we have some traces to show how the work overlaps? I'm curious to know what main frame work we could have done during those scripts of we had a yielding system.

--
You received this message because you are subscribed to the Google Groups "platform-architecture-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to platform-architect...@chromium.org.
To post to this group, send email to platform-arc...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CABg10jxXN%2BFcoJUVHtF7_9%2BeRuWEK_NCk6hoStx6GH2%2Bt5QNwQ%40mail.gmail.com.

Kentaro Hara

unread,
Jun 15, 2016, 7:50:54 AM6/15/16
to Elliott Sprehn, platform-architecture-dev, Takashi Sakamoto
tasak@: Can you upload the traces?

(But I think it would be anyway really problematic that the third-party script blocks the main frame's tasks for >500 ms :-)



Kentaro Hara

unread,
Jun 16, 2016, 1:04:22 AM6/16/16
to Elliott Sprehn, platform-architecture-dev, Takashi Sakamoto
This is a tracing result when I loaded qq.com on Linux desktop (the first 6 seconds). I also attached a trace file to this email.






trace_Thu_Jun_16_2016_1.54.49_PM.json.gz

Takashi Sakamoto

unread,
Jun 16, 2016, 1:27:38 AM6/16/16
to Kentaro Hara, Elliott Sprehn, platform-architecture-dev

Kentaro Hara

unread,
Jun 17, 2016, 3:45:23 AM6/17/16
to Takashi Sakamoto, Elliott Sprehn, platform-architecture-dev
I tried to prototype the restricted nested message loop and see how it improves UX in real-world websites, but noticed that it's hard to prototype without having the per-iframe scheduler.

To prototype the idea, we need to interrupt a third-party iframe (<-- this is easily doable) and run main frame's task in a nested message loop of the iframe. However, currently there is no way to pick up main frame's task because tasks from various frames are mixed in the default task runner. If we mistakenly run the iframe's task in a nested message loop of the iframe, it will just break the order of task executions :/

So it looks like that we need to tie all tasks and timers with iframes before experimenting with the restricted nested message loop.



Ojan Vafai

unread,
Jun 17, 2016, 4:06:48 AM6/17/16
to Kentaro Hara, Takashi Sakamoto, Elliott Sprehn, platform-architecture-dev
Reply all
Reply to author
Forward
0 new messages