Make NS_NewURI work off main thread and remove nsIProtocolHandler.newURI
Categories
(Core :: Networking, enhancement, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox69 | --- | fixed |
People
(Reporter: valentin, Assigned: valentin)
References
(Depends on 1 open bug)
Details
(Whiteboard: [necko-triaged])
Attachments
(22 files, 1 obsolete file)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
Now that bug 1532253 has landed we may be able to "tie up all the loose ends".
(In reply to Valentin Gosu [:valentin] from bug 1532253 comment #5)
The protocols that are left:
- moz-gio - depends on prefs
- moz-icon - calls IOService.newURI
- view-source - calls NS_NewURI for inner part of the URI - we make it call NS_NewURIOnAnyThread
- resource - extends SubstitutingProtocolHandler (substitution flags + jar)
- moz-extension - extends SubstitutingProtocolHandler (substitution flags + jar)
- jar - nsJARURI::SetSpecWithBase calls ioServ->NewURI
- about - calls NS_GetAboutModule (can be JS implemented)
Apart from these there's nsExternalProtocolHandler::NewURI which simply instantiates a new nsSimpleURI, but we can't fall back to it if the above protocols aren't handled.
NS_NewURI should be replaced by NS_NewURIOnAnyThread.
nsIOService.newURI should call directly into NS_NewURIOnAnyThread
nsIProtocolHandler.newURI should be removed. All calls should be replaced with either NS_NewURIOnAnyThread in C++ or Services.io.newURI in JS.
Assignee | ||
Comment 1•6 years ago
•
|
||
So I've got a very unpolished set of patches that moves the creation of most protocol types to NS_NewURIOnAnyThread.
However, I don't think we can work around the protocol handlers for resource and moz-extension URIs.
So the strategy would be to make those protocol handlers (just .newURI() actually) threadsafe. This would be accomplished by making SubstitutingProtocolHandler use NS_INLINE_DECL_THREADSAFE_REFCOUNTING, then making sure that all member variables of SubstitutingProtocolHandler, nsResProtocolHandler, ExtensionProtocolHandler that are touched by newURI be accessed under a lock (when read off main thread or modified. Reading them on the main thread doesn't really need to lock them if they can only be changed on the main thread).
nsResProtocolHandler::ResolveSpecialCases
nsResProtocolHandler::mAppURI
nsResProtocolHandler::mGREURI
nsResProtocolHandler::mApkURI
ExtensionProtocolHandler::ResolveSpecialCases ->
SubstitutingProtocolHandler::HasSubstitution
SubstitutingProtocolHandler::mSubstitutions
ExtensionProtocolHandler::ResolveSpecialCases ->
ExtensionPolicyService::GetGeneratedBackgroundPageUrl ->
-
ExtensionPolicyService::mExtensionHosts
-
maybe
WebExtensionPolicy::mBackgroundScripts
- but it doesn't seem to change after the constructor, so this may be OK.
SubstitutingProtocolHandler::GetSubstitution -
SubstitutingProtocolHandler::mSubstitutions
Assignee | ||
Comment 2•6 years ago
|
||
Assignee | ||
Comment 3•6 years ago
|
||
Depends on D30692
Assignee | ||
Comment 4•6 years ago
|
||
Depends on D30693
Assignee | ||
Comment 5•6 years ago
|
||
These URL types need both specific applications to be installed on Linux, and for the pref to list them as supported.
We do these checks in nsGIOProtocolHandler::NewChannel instead of performing them when creating the URLs.
Depends on D30694
Assignee | ||
Comment 6•6 years ago
|
||
This way all of the nsIURI creation will go through NS_NewURIOnAnyThread.
NS_NewURIOnAnyThread will be renamed to NS_NewURI in the final patch.
Depends on D30695
Assignee | ||
Comment 7•6 years ago
|
||
Depends on D30696
Assignee | ||
Comment 8•6 years ago
|
||
- Add main thread assertions for "resource" and "moz-extension" protocols
- Use ::GetSingleton() for resource and moz-extension protocol handlers
Depends on D30697
Assignee | ||
Comment 9•6 years ago
|
||
This is achieved by adding a RWLock to SubstitutingProtocolHandler
Depends on D30698
Assignee | ||
Comment 10•6 years ago
|
||
Depends on D30699
Assignee | ||
Comment 11•6 years ago
|
||
Depends on D30700
Assignee | ||
Comment 12•6 years ago
|
||
Depends on D30701
Assignee | ||
Comment 13•6 years ago
|
||
Depends on D30702
Assignee | ||
Comment 14•6 years ago
|
||
Depends on D30703
Assignee | ||
Comment 15•6 years ago
|
||
nsSimpleURI doesn't really have the concept of a relative URI.
Since unknown protocol schemes will ultimately fall back to using nsSimpleURI,
we need to make sure that resolving a URI with certain base still works as
before, when those URIs were nsStandardURLs, created by the protocol handlers.
To achieve this we check to see if the "relative path" has a scheme. If it
does, we just return it, to be parsed by NS_NewURI. Otherwise, we use
MozURL (based on rust-url) to figure out the correct relative URL we should
return. This by itself manages to fix several failing web-platform tests.
Depends on D30704
Assignee | ||
Comment 16•6 years ago
|
||
Before, we'd try to create a URI using the GIO protocol handler, and if that
succeeded, we'd return the protocol handler.
Now we can't return it if NS_NewURI succeeds, because NS_NewURI doesn't check
the protocol handler anymore. So instead we just instantiate the handler,
check if the scheme is supported, and if so return it.
Depends on D30705
Assignee | ||
Comment 17•6 years ago
|
||
This is needed to pass a web-platform-test. Since unknown protocols use
nsSimpleURI and nsSimpleURI::GetHost returns an error code, that will fail.
Instead, we instantiate an nsStandardURL for the ssh scheme.
Once we change nsSimpleURI to be backed by MozURL we can probably remove this.
Depends on D30706
Assignee | ||
Comment 18•6 years ago
|
||
Depends on D30707
Assignee | ||
Comment 19•6 years ago
|
||
These were fixed by the improvements added to nsSimplerURI::Resolve()
Depends on D30708
Assignee | ||
Comment 20•6 years ago
|
||
Depends on D30709
Assignee | ||
Comment 21•6 years ago
|
||
Depends on D30710
Assignee | ||
Comment 22•6 years ago
|
||
There's a web-platform-test expecting the origin for a ssh URI to be null
Depends on D30711
Assignee | ||
Comment 23•6 years ago
|
||
The only protocol that can't be created off the main thread at the moment is
moz-extension, and that can be handled at a later time.
Depends on D30712
Comment 24•6 years ago
|
||
This change would have a huge impact on c-c.
Comment 25•6 years ago
|
||
Thanks for the heads-up. You don't intend to land this during the 68 cycle, right? I'm a bit confused by the large amount of changes here. What would be the impact? Looks like we have seven protocol handlers which implement NewURI()
:
https://searchfox.org/comm-central/search?q=%3A%3ANewURI(&case=false®exp=false&path=mailnews%2F
Assignee | ||
Comment 26•6 years ago
|
||
(In reply to Jorg K (GMT+2) from comment #25)
Thanks for the heads-up. You don't intend to land this during the 68 cycle, right?
This is definitely not going to land during 68. If all goes well it will be in 69. Just reviewing the patches will likely take a while.
I'm a bit confused by the large amount of changes here. What would be the impact? Looks like we have seven protocol handlers which implement
NewURI()
:
https://searchfox.org/comm-central/search?q=%3A%3ANewURI(&case=false®exp=false&path=mailnews%2F
To accommodate c-c it seems we can ifdef most of those schemes in NS_NewURI{OnAnyThread}.
It seems nsImapService::NewURI
and nsPop3Service::NewURI
are slightly more complex, and but we can handle them in a similar fashion to the resource and moz-extension URLs
What I'd propose is that at the end of NS_NewURI we add something like:
#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
return NS_NewThunderbirdURI(aURI, aSpec, aCharset, aBaseURI, aIOService);
#endif
Then NS_NewThunderbirdURI
can be used to deal with the any of the quirks of those implementations.
Jorg, can you file a separate bug for porting this bug to c-c? I think this might be a good opportunity to remove some of the extra protocol handlers, and make the c-c URIs a bit nicer. I have some ideas for that.
Comment 27•6 years ago
|
||
Thanks, I filed bug 1550945. Can you please point out what the troublesome bits are.
Comment 28•6 years ago
|
||
Comment on attachment 9064153 [details]
Bug 1536744 - Make sure we only return an origin for schemes that are allowed in the URL spec r=mayhemer,baku
Revision D30712 was moved to bug 1553105. Setting attachment 9064153 [details] to obsolete.
Assignee | ||
Comment 29•6 years ago
|
||
These should be removed once bug 1553105 lands.
Depends on D30713
Comment 30•6 years ago
|
||
Comment 31•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/08145972450d
https://hg.mozilla.org/mozilla-central/rev/fe9ee62644df
https://hg.mozilla.org/mozilla-central/rev/579eff229d65
https://hg.mozilla.org/mozilla-central/rev/e0ebd1ac8ef4
https://hg.mozilla.org/mozilla-central/rev/91e6edcfa40c
https://hg.mozilla.org/mozilla-central/rev/3ff470f6fa58
https://hg.mozilla.org/mozilla-central/rev/0a27f68d2387
https://hg.mozilla.org/mozilla-central/rev/2b7f7b802744
https://hg.mozilla.org/mozilla-central/rev/7c0e5643c209
https://hg.mozilla.org/mozilla-central/rev/dcdc05e86666
https://hg.mozilla.org/mozilla-central/rev/bbb8bd167fbc
https://hg.mozilla.org/mozilla-central/rev/bf85e54d26dd
https://hg.mozilla.org/mozilla-central/rev/1c6b4a75a605
https://hg.mozilla.org/mozilla-central/rev/d418e0d5594a
https://hg.mozilla.org/mozilla-central/rev/2dead78339e0
https://hg.mozilla.org/mozilla-central/rev/def28b67d7d8
https://hg.mozilla.org/mozilla-central/rev/15153522a5d9
https://hg.mozilla.org/mozilla-central/rev/d348b926aa2a
https://hg.mozilla.org/mozilla-central/rev/feb205a5e548
https://hg.mozilla.org/mozilla-central/rev/4156260290c8
https://hg.mozilla.org/mozilla-central/rev/e29e51a1dfd4
https://hg.mozilla.org/mozilla-central/rev/ec6db16dbb4e
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Updated•4 years ago
|
Description
•