Factor parts of WebExtensionPolicy into a threadsafe core type
Categories
(WebExtensions :: General, enhancement)
Tracking
(firefox107 fixed)
| Tracking | Status | |
|---|---|---|
| firefox107 | --- | fixed |
People
(Reporter: nika, Assigned: nika)
References
Details
Attachments
(8 files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
A way to reference a WebExtensionPolicy from any thread will be necessary to make nsIPrincipal threadsafe (bug 1443925). It will both be needed as part of implementing ContentPrincipal::AddonPolicy() as well as part of supporting NS_URIChainHasFlags on any thread (bug 1793463).
The particular fields which we want to be make threadsafe includes WebAccessibleResource in order to implement NS_URIChainHasFlags. This will require replacing the regex backend used by MatchGlob from using the JS engine, so that it can be used on any thread. This will require us to switch to the rust regex library (bug 1693271), as well as split out the WebIDL wrappers for the various types (MatchGlob, MatchPattern, MatchPatternSet), so that the core types can be made threadsafe.
| Assignee | ||
Comment 1•3 years ago
|
||
This threadsafe core type also acts as a weak reference to the main-thread
WebExtensionPolicy when needed. This will be used when information about a
WebExtension is needed to be accessible off-main-thread in the future.
Depends on D158878
| Assignee | ||
Comment 2•3 years ago
|
||
The mutator methods were never used, so were easy to remove, allowing the type
to be made threadsafe. The main potential for performance regression is that
the string based Contains method now uses NS_Atomize instead of
NS_AtomizeMainThread, however this is only called in once place
(WebExtensionPolicy::HasPermission). If it turns out to be an issue, we can
move the atomization into the caller to keep it using NS_AtomizeMainThread.
Depends on D158879
| Assignee | ||
Comment 3•3 years ago
|
||
These getters are never called and will make making the core of MatchGlob
threadsafe more annoying.
Depends on D158880
| Assignee | ||
Comment 4•3 years ago
|
||
The outer cycle-collected wrapper type is unfortunately still required by
WebIDL in order to keep the JS API working.
Depends on D158881
| Assignee | ||
Comment 5•3 years ago
|
||
Similar to MatchGlob, this is fairly straightforward, but is complicated
slightly by MatchPatternSet, which allows being destructured into the
contained MatchPattern instances in a [Constant] method. To handle this a
cache is added for the wrappers in the cycle-collected MatchPatternSet.
Depends on D158882
| Assignee | ||
Comment 6•3 years ago
|
||
In order to make WebAccessibleResource threadsafe, as well as other places, it
needs to be possible to look up a WebExtensionPolicyCore from any thread.
This is handled by using a static method on the ExtensionPolicyService for this
task, and keeping a seperate mutex-guarded static table under the hood.
Theoretically the table within ExtensionPolicyService() could also be
removed, however I held off on doing that in case it would have a negative
performance impact to take extra locks and follow extra pointers.
Depends on D158883
| Assignee | ||
Comment 7•3 years ago
|
||
Now that all fields and methods in WebAccessibleResource have been made
threadsafe, we can make the type itself be threadsafe.
Depends on D158884
| Assignee | ||
Comment 8•3 years ago
|
||
This will be required in the future to make getting protocol flags for
moz-extension:// URIs threadsafe.
Depends on D158885
Comment 10•3 years ago
|
||
Backed out for causing build bustages on RustRegex.h
- Backout link
- Push with failures
- Failure Log
- Failure line: /builds/worker/workspace/obj-build/dist/include/mozilla/RustRegex.h:630:24: error: unused variable 'view' [-Werror,-Wunused-variable]
Log tier 2: https://treeherder.mozilla.org/logviewer?job_id=392996025&repo=autoland
Comment 11•3 years ago
|
||
Comment 12•3 years ago
|
||
Backed out for causing build bustages
- Backout link
- Push with failures
- Failure Log
- Failure line: clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[4]: *** [/builds/worker/checkouts/gecko/config/makefiles/rust.mk:433: force-cargo-library-build] Error 101
Comment 13•3 years ago
|
||
| Assignee | ||
Updated•3 years ago
|
Comment 14•3 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/61417ba55b4c
https://hg.mozilla.org/mozilla-central/rev/ef9dcb4d17d2
https://hg.mozilla.org/mozilla-central/rev/f1d329c29295
https://hg.mozilla.org/mozilla-central/rev/70fb967a388d
https://hg.mozilla.org/mozilla-central/rev/9e563403fa06
https://hg.mozilla.org/mozilla-central/rev/6fb4337b5bc0
https://hg.mozilla.org/mozilla-central/rev/a891737169cc
https://hg.mozilla.org/mozilla-central/rev/00ee36d3c47b
Description
•