Bug 194305 - Web Inspector: we should lazily import three.js
Summary: Web Inspector: we should lazily import three.js
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-02-05 14:55 PST by Devin Rousso
Modified: 2019-08-06 10:43 PDT (History)
7 users (show)

See Also:


Attachments
Patch (3.77 KB, patch)
2019-08-05 09:08 PDT, Devin Rousso
bburg: review+
drousso: commit-queue?
Details | Formatted Diff | Diff
Archive of layout-test-results from ews212 for win-future (13.50 MB, application/zip)
2019-08-05 10:43 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2019-02-05 14:55:19 PST
In the case that the Layers tab isn't even enabled, we're still loading three.js.  We should avoid loading it until the first time we show the Layers tab.
Comment 1 Radar WebKit Bug Importer 2019-02-05 14:55:38 PST
<rdar://problem/47832436>
Comment 2 Devin Rousso 2019-08-05 09:08:52 PDT
Created attachment 375529 [details]
Patch

One possible "solution" that's quite hacky :|
Comment 3 Build Bot 2019-08-05 10:43:36 PDT Comment hidden (obsolete)
Comment 4 Build Bot 2019-08-05 10:43:38 PDT Comment hidden (obsolete)
Comment 5 Nikita Vasilyev 2019-08-05 11:33:07 PDT
Comment on attachment 375529 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=375529&action=review

> Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js:149
> +                request.open("GET", url, false);

Note that the syncronous XHR on the main thread is already deprecated in Chrome and Firefox. If WebKit deprecates it, this would stop working.
Comment 6 Brian Burg 2019-08-06 10:28:27 PDT
Comment on attachment 375529 [details]
Patch

r=me on the general approach

Is there some reason this can't be a fetch instead?
Comment 7 Devin Rousso 2019-08-06 10:40:05 PDT
(In reply to Brian Burg from comment #6)
> Is there some reason this can't be a fetch instead?
`fetch` is async.

The big "issue" with any attempt at lazy-loading something is that we need a way to basically block everything else (or queue it) until the lazy-loading is done.  I'd tried prototyping something like this in the past for <https://webkit.org/b/172249>, but one of the issues I encountered was that there are SO many entry points to a tab (or it's main content view) that blocking/queuing them all is a tall order.

In this case, thinking about it more, since THREE.js is only used in this file, I could create a local defer queue.  I'll experiment and see.