Open Bug 1893948 Opened 2 months ago Updated 2 days ago

Avoid sync IO in parental controls service (provide threadsafe + lazily-looked-up implementation)

Categories

(Core :: Networking, defect, P2)

Unspecified
Windows
defect

Tracking

()

People

(Reporter: Gijs, Assigned: acreskey, NeedInfo)

References

Details

(Whiteboard: [necko-triaged][necko-priority-queue])

Attachments

(1 file)

The instance that tripped filing bug 1570616 was using CoCreateInstance in the parental controls service. In bug 1584613 this was replaced with a registry read.

This happens on the main thread when initializing the HTTP handler code. The HTTP handler code then has a member that independently tracks whether parental controls are available.

I suspect the mirroring is there because nsHttpHandler needs access off-mainthread. One potential improvement that wouldn't require too many API changes would be to avoid the mirroring, create a threadsafe API on nsParentalControlService and back it with a threadsafe member there which we initialize lazily (that is, send off an idle task to fetch the information off-main-thread when the service is initialized, and fall back to the sync mainthread fetch if we need the information before we've fetched it on the idle task). However, I'm not super familiar with this code and I don't know if the size of the problem warrants that level of complexity.

The call to the parental controls service during the Http handler init was added in bug 1891483 recently.
Dennis, how early do we need that information. Could we defer that operation to a later time?

Flags: needinfo?(djackson)
See Also: → 1891483

Note that we also check it in TRRService::Init - which happens relatively soon after startup

I didn't add the call in the Http Handler Init in 1891483, that was already there. I only added a read of the local member which was already set. We need this information to know whether to use Encrypted Client Hello (or not) when making TLS connections. We don't want to use it if parental controls are enabled. I expect we need this information very early in startup no matter what (considering the TRR use case as well) - but it sounds like moving it off-main thread is a reasonable way to go..

Flags: needinfo?(djackson)
Severity: -- → S3
Priority: -- → P2
Whiteboard: [necko-triaged][necko-new]
Whiteboard: [necko-triaged][necko-new] → [necko-triaged][necko-priority-new]
Whiteboard: [necko-triaged][necko-priority-new] → [necko-triaged][necko-priority-queue]

https://searchfox.org/mozilla-central/rev/2e7374599f4020d0490ec8c5e877c179c9e153c9/netwerk/protocol/http/nsHttpHandler.cpp#471-475

nsCOMPtr<nsIParentalControlsService> pc =
    do_CreateInstance("@mozilla.org/parental-controls-service;1");
if (pc) {
  pc->GetParentalControlsEnabled(&mParentalControlEnabled);
}
  • add a method that returns that value
  • make the TRR service call into the nsHttpHandler code here
Assignee: nobody → acreskey

Create a background task to query the state of the parental controls service to prevent main thread blockage.

(In reply to Valentin Gosu [:valentin] (he/him) {{ FYI: OOO 14 June - 4 August }} from comment #4)

https://searchfox.org/mozilla-central/rev/2e7374599f4020d0490ec8c5e877c179c9e153c9/netwerk/protocol/http/nsHttpHandler.cpp#471-475

nsCOMPtr<nsIParentalControlsService> pc =
    do_CreateInstance("@mozilla.org/parental-controls-service;1");
if (pc) {
  pc->GetParentalControlsEnabled(&mParentalControlEnabled);
}
  • add a method that returns that value
  • make the TRR service call into the nsHttpHandler code here

Thanks Valentin.
We can discuss in the patch; I've implemented this and while I'm not familiar with the startup order, we may end up racing on the background thread determination of the parental controls state.

Pushed by acreskey@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/57a8ef5f87bf
Avoid sync IO in parental controls service (provide threadsafe + lazily-looked-up implementation) r=necko-reviewers,kershaw

Backed out for causing multiple failures.




  • Push with failures - gl failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | dom/canvas/test/webgl-conf/generated/test_2_conformance__glsl__misc__glsl-vertex-branch.html | assertion count 1 is more than expected 0 assertions





Flags: needinfo?(acreskey)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: