Open Bug 1603167 Opened 5 years ago Updated 2 years ago

Restructure Sync.jsm and Error.jsm to better deal with lazy loading

Categories

(Remote Protocol :: Agent, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: ato, Unassigned)

References

Details

(Whiteboard: [puppeteer-beta2-mvp])

Attachments

(2 obsolete files)

Sync.jsm and Error.jsm export a lot of symbols. This is not in itself a bad thing, considering ChromeUtils.import and the forthcoming ES modules import() statement supports it.

But it does not play nicely with XPCOMUtils.defineLazyGetters as outlined in bug 1601618.

Sync.jsm I think is easy: we should create a subfolder remote/sync/ and put each of the synchronisation primitives as separate classes within the subfolder.

I’m more conflicted about Error.jsm because of the number of files it would generate, but I wouldn’t be opposed to imports such as chrome://remote/content/error/UnsupportedError.jsm.

Priority: -- → P3

Why do you think that we should split those JSMs into individual ones? They are kinda small, and I don't see a reason why we would have to deal with such a complexity.

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #1)

Why do you think that we should split those JSMs into individual ones? They are kinda small, and I don't see a reason why we would have to deal with such a complexity.

Maybe I misinterpreted your earlier comment that caused me to file this bug:

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from bug 1601618 comment #3)

In those cases it would be good if our modules would just export a single namespace. Very good example is OS. Note that we should do as much as possible lazy loading of modules for JSWindowActor child instances. Otherwise memory usage will spike up, and performance will be degraded.

One way to make it easier to import modules that export multiple symbols is to make a module export only a single symbol.

ochameau has been a strong proponent of this approach in the past and had some good reasons for it that I’ve now forgot. My impression is that the one-class-per-module organisation is pretty consistent throughout DevTools? Could you please enlighten us?

Flags: needinfo?(poirot.alex)
Flags: needinfo?(hskupin)

This also applies to various other global modules like OS (OS.File, OS.Path), NetUtils etc.. As such I would really see following that style.

Flags: needinfo?(hskupin)
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Priority: P3 → P1
Whiteboard: [puppeteer-beta-reserve]
Summary: Restructre Sync.jsm and Error.jsm to better deal with lazy loading → Restructure Sync.jsm and Error.jsm to better deal with lazy loading

(In reply to Andreas Tolfsen ❲:ato❳ from comment #2)

ochameau has been a strong proponent of this approach in the past and had some good reasons for it that I’ve now forgot. My impression is that the one-class-per-module organisation is pretty consistent throughout DevTools? Could you please enlighten us?

It helps knowing from which JSM a given class comes from.
If you have a class called Foo, you will look for Foo.jsm.
I think that's the first reason for one-class-per-module.
A second reason would be lazy loading.
If you only use one of the many classes, you can load less JS and loading any byte of JS is an expensive operation.

Flags: needinfo?(poirot.alex)
Whiteboard: [puppeteer-beta-reserve] → [puppeteer-beta-mvp]
Attachment #9118869 - Attachment is obsolete: true
Attachment #9118868 - Attachment is obsolete: true

Based on the discussion in the Phabricator revisions I'm going to stop work for now.

Assignee: hskupin → nobody
Status: ASSIGNED → NEW
Priority: P1 → P2
Whiteboard: [puppeteer-beta-mvp] → [puppeteer-beta-reserve]
Priority: P2 → P3
Whiteboard: [puppeteer-beta-reserve] → [puppeteer-beta2-mvp]
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: