uBlock icon indicating copy to clipboard operation
uBlock copied to clipboard

WebExtensions API

Open ghost opened this issue 11 years ago • 30 comments

https://blog.mozilla.org/addons/2015/08/21/the-future-of-developing-firefox-add-ons/

ghost avatar Aug 21 '15 18:08 ghost

Much like making uBlock for Microsoft Edge, this should mean easier cross-platform development going forward.

lewisje avatar Aug 22 '15 12:08 lewisje

Yeah and the death of many XUL, XPCOM and XBL add-ons. Hey...... What is Ublock built from?

LimboSlam avatar Aug 23 '15 02:08 LimboSlam

Even though there is an options.xul file in uBlock, I believe it's made with Jetpack, because it is restartless; also, I searched for the dreaded require('chrome') or require("chrome") and didn't even find so much as a require( in the codebase, and also the install.rdf file says the extension is bootstrapped and multi-process compatible.

TL;DR: uBlock will be fine in our brave new multi-process world.

lewisje avatar Aug 23 '15 02:08 lewisje

require('chrome') is not used because uBlock is not a SDK addon. The Firefox port currently uses the Components object to access XPCOM which is getting depreciated in around 18 months.

Hopefully the new WebExtensions API is fully compatible with Chrome's and uBlock would be just fine.

quilloss avatar Aug 23 '15 11:08 quilloss

I understand completely Mozilla's move. From a technical standpoint, maintaining and having to deal with huge amount of legacy code is a burden on resources, stability, performance and ability to easily improve performance or add features. There is a lot of silly overreaction going on (nowhere do they say they will limit FF to only a Chrome-like API).

Anyways, technical commentary. I see that FF41 will ship a webRequest-clone API. I have worries about its implementation though.

As far as I can see, the implementation of onBeforeRequest will cause the content process to be blocked until a network request has been evaluated[1], while in uBlock the content process is minimally blocked, just the time to put key information in a circular buffer, that is all. In uBlock, the content process does not wait on the extension to decide whether a network request has to be blocked or not, this is all really done in the chrome process. Firefox's current implementation will cause the content process to be blocked until it has been completely decided whether network request must be blocked.

The way @Deathamns implemented this in uBlock resulted in minimally blocking the content process, and this shows when observing performance of uBlock (and uMatrix which shares much of the same Firefox-specific code) in e10s -- compared to other blockers out there.

After I took over the code I merely extended what was there to use a circular buffer mechanism to receives and store more information from the content process (to fix #211), which information is later retrieved in the HTTP observer (chrome process) when network requests have to be evaluated -- still minimally blocking the content process.

The duration for which the content process is blocked matters in e10s, as all tabs will share the same content process.

Maybe it's an idea they could pick from uBlock's code base, but then, they have better knowledge of all the Firefox's inner workings, there might be other reasons that I am unaware of to favor their chosen implementation.


[1] content process side, blocked until a response is received from chrome process side

gorhill avatar Aug 23 '15 13:08 gorhill

https://bugzilla.mozilla.org/show_bug.cgi?id=1163862 This bug seems to indicate that they plan to use HTTP observers instead of content policies for onBeforeRequest in the future.

quilloss avatar Aug 23 '15 16:08 quilloss

Will nsIContentPolicy be deprecated too?

lewisje avatar Aug 24 '15 03:08 lewisje

@mattatobin: possibly implement your own version of WebExtension API when it becomes stable and officially part of the Firefox code? Is that in our plans?? Is it even possible without using certain technology's we don't support, yet??

But of course finish the current projects we have going, that is our main duty.

LimboSlam avatar Aug 24 '15 18:08 LimboSlam

I've put in a request for Firefox to implement the declarativeWebRequest API, and if it does, that will be a definite advantage over Chrome, which has for years kept it at an experimental state, available in Beta and Developer editions but not Stable.

lewisje avatar Aug 25 '15 03:08 lewisje

repository of extensions that work perfectly fine

There is no way to avoid making FF into a multiprocess-friendly application. To think that FF will stay forever a single process application is nonsense. Once you accept this conclusion, all the rest follows: the re-factoring is inevitable in order for FF to stay relevant long-term.

gorhill avatar Aug 25 '15 13:08 gorhill

Multi-process doesn't even have anything to do with what extension framework you choose to use. Also, multi-process is not a requirement in any way shape or form for using multiple processors (despite the similarity in name). So, please keep this argument out of this because it's completely irrelevant to browser extensibility.

wolfbeast avatar Aug 25 '15 15:08 wolfbeast

@wolfbeast pay attention to what I quoted:

repository of extensions that work perfectly fine

No, the repository of extensions does not work "perfectly fine" with e10s.

gorhill avatar Aug 25 '15 15:08 gorhill

Will uBlock Origin continue to support Chromium as an independent target despite what Chromium does?

I don't know.

Will uBlock Origin continue to support Opera as an independent target despite what Opera does?

I don't know.

Will uBlock Origin continue to support Firefox as an independent target despite what Firefox does?

I don't know.

Will uBlock Origin continue to support Pale Moon as an independent target despite what Pale Moon does?

I don't know.

Will you continue to maintain uBlock Origin forever?

I don't know.

Bottom-line: I don't know what will happen in the future, so I don't commit to anything.

gorhill avatar Aug 25 '15 15:08 gorhill

@gorhill : implementing the extension using WebExtensions API would provide an easy to use support for system-wide content blocking for FirefoxOS, quite a game changer IMO :)

Plus, most FirefoxOS phones have a "small" hardware, so it would probably boost the phone performances as well while navigating

temsa avatar Nov 10 '15 15:11 temsa

implementing the extension using WebExtensions API would provide

It's already done, that is what the Chromium version is.

gorhill avatar Nov 10 '15 18:11 gorhill

Yes... And no : I'll personally consider it as done when I'll see it available on the firefox marketplace so I can install it on my phone ;)

On Tue, Nov 10, 2015, 19:17 Raymond Hill [email protected] wrote:

implementing the extension using WebExtensions API would provide

It's already done, that is what the Chromium version is.

— Reply to this email directly or view it on GitHub https://github.com/gorhill/uBlock/issues/622#issuecomment-155520329.

temsa avatar Nov 11 '15 18:11 temsa

@gorhill While I believe the Chromium version should run fine on the initial WebExtensions release (currently set to FF48), you do have to add at least one thing to the manifest.json file specific to Firefox: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/applications

After that, testing it is simple: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Porting_from_Google_Chrome

And then you can upload the "WebExtensions" version to AMO right away (they're currently accepting them for review).

Daktyl198 avatar Mar 15 '16 14:03 Daktyl198

The new API is coming and the old one is being killed. Perhaps it's time this issue becomes a priority.

I believe that the cause of #1973 is most likely that @uptonn is of the 1% of users that Mozilla is testing their multi-process version from on using Firefox 48 public release.

coladict avatar Sep 19 '16 19:09 coladict

uBO works fine on Nightly -- most likely explanation is that the SQL database was corrupted and this broke uBO's internals. These cases of corrupted SQL database crop up once in a while (it's out of uBO's control, it merely uses the FF API to access the SQL database).

gorhill avatar Sep 19 '16 19:09 gorhill

Started to work on this, related Bugzilla entry: https://bugzilla.mozilla.org/show_bug.cgi?id=1309926.

Currently blocked because of an incomplete API:

a

uBO's Port.onMessage's listener is not being given the port argument when being called.

Need to open a Bugzilla entry for this.

gorhill avatar Oct 18 '16 19:10 gorhill