samuelmaddock / electron-browser-shell

A minimal, tabbed web browser with support for Chrome extensions—built on Electron.
GNU General Public License v3.0
354 stars 69 forks source link

Extension Manifest V3 not supported #38

Open samuelmaddock opened 3 years ago

samuelmaddock commented 3 years ago

Manifest V3 (MV3) is that latest versions of the Chrome extensions API which is now stable in Chrome.

It's partially supported in Electron at the moment since electron/electron#27562 was introduced.

Known affected extensions

I don't know of any widely used extensions shipping with MV3 yet, but there will be as MV2 begins to be phased out.

Possible solutions

electron-chrome-extensions provides new extension APIs by injecting them with JavaScript. This is done in Electron preload scripts. Instead of background hosts using a WebContents instance, MV3 uses service workers.

Electron doesn't have support for injecting JS into a service worker context yet. The API will need to be expanded to support new contexts. Work on specing out changes has started in electron/governance#366

schetle commented 2 years ago

Is there any news on electron's support for injecting JS into service worker contexts?

https://developer.chrome.com/docs/extensions/mv3/mv2-sunset/

Here's the V2 support timeline, and so we're looking to get upgraded to V3 before V2 is completely killed off.

samuelmaddock commented 2 years ago

Is there any news on electron's support for injecting JS into service worker contexts?

Currently no update. I've spent time researching what it would take and the amount of work is non-trivial.

Electron's preload scripts work in a secure environment thanks to the effort of extension content scripts which provide an isolated JS context. Node's globals and other variables within preload scripts are separate from the main JS context. This is how V8's binding system works: https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/bindings/core/v8/V8BindingDesign.md#world

The problem is when trying to do the same thing with Workers (Service, Web, Shared). Support for isolated worlds/contexts within a worker environment isn't something that exists yet. This has been attempted before without context isolation which isn't a secure approach (see https://github.com/electron/electron/pull/28923#issuecomment-834671017).

At a high-level, here's a list of what might be needed:

Then there's a few other requirements just for API design within Electron. A design proposal might be needed for that in the API governance repo.

I do realize the importance of this work prior to Chrome dropping support of MV2, however, I don't currently have a roadmap for these contributions.

lengband commented 1 year ago

@samuelmaddock hello. May I know the current status of this matter? Is there any news on electron's support for injecting JS into service worker contexts? i am using electron-chrome-extensions but it only supports V2.

samuelmaddock commented 1 year ago

Electron does not yet support preload scripts for service workers. I'm not aware of others currently working towards adding this.

I spent time on it a couple of months ago, but I have no estimate and I'm not close to a solution.

PascalPixel commented 1 year ago

In case anyone is interested, there is movement towards Manifest v3; https://github.com/electron/electron/pull/39395

ductridev commented 5 months ago

any updates on this :(

samuelmaddock commented 5 months ago

I'm currently awaiting comments on my RFC which would unblock this https://github.com/electron/rfcs/pull/4

lengband commented 5 months ago

Hello, @samuelmaddock Are there any updates on this? And is it difficult for Electron to support preload scripts for service workers? If it did, it would be a cool thing.

PascalPixel commented 5 months ago

Hello, @samuelmaddock

Are there any updates on this?

And is it difficult for Electron to support preload scripts for service workers? If it did, it would be a cool thing.

Depends on this https://github.com/electron/rfcs/pull/4

lengband commented 5 months ago

This RFC has been around for a long time...

samuelmaddock commented 1 month ago

Moved RFC to https://github.com/electron/rfcs/pull/8 due to GitHub bug...

Not much activity yet, but Electron's API WG is starting to meet regularly to work through APIs and RFCs.

samuelmaddock commented 4 days ago

API working group meetings have been a success. The Preload Realms RFC was just merged after approval 🎉

Next step is to finish implementing preload realms and open a PR to Electron. I don't have any estimates for how long this will take me, but my hope is we have MV3 supported by end of year, if not sooner 🙏

For anyone interested in this, please consider sponsoring my work 🙇

ductridev commented 4 days ago

awesome 😎