Closed Bug 1848708 Opened 1 year ago Closed 1 year ago

Though Glean global is available in privileged "about:" contexts, none of the instrumentation APIs can be called due to CreateWrapperDeniedForOrigin errors

Categories

(Toolkit :: Telemetry, defect, P1)

defect

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: chutten|PTO, Assigned: chutten|PTO)

References

Details

Attachments

(7 files, 1 obsolete file)

I neglected to test beyond "Glean and GleanPings are available in privileged about contexts" and thus missed that no instrumentation APIs actually work. Trying e.g. Glean.aCategory.aName.record() returns Permission denied for <%2$S> to create wrapper for object of class %1$S.

Nika explains that XPCOM-wrapped JS isn't allowed in content contexts, regardless of privilege. So it seems as though we're going to have to go full webidl to make this work:

  • Move dom/chrome-webidl/ interfaces to dom/webidl/ and replace [ChromeOnly] with [Func="nsGlobalWindowInner::IsGleanNeeded"]
  • Move interfaces out of t/c/g/xpcom/nsIGleanMetrics.idl to webidl/, rewriting to webidl (no more AUTF8String. Learn to love DOMString. And drop those nsI prefixes. And nsISupports is now any or object.)
  • Reimplement moved interfaces in new headers that you reference in dom/bindings/Bindings.conf
  • Basically follow https://firefox-source-docs.mozilla.org/dom/webIdlBindings/index.html and see what happens.

It'd be nice if we could do this piecemeal, starting with only supporting Event since that's the interesting one, but I'm getting a sinking feeling that we'll have to convert this all in one go.

Since we're exposing Glean types in not-chrome-only contexts like privileged
"about:" pages, we can't live in chrome-webidl/ any longer.

ni?nika -- Is https://phabricator.services.mozilla.com/D186267 about right? I'm specifically wondering how much of my cargo cult is needed (can I just... drop? nsISupports? if we're not doing XPCOMish things?), whether my hunch about using metrics' WrapObject to generate the JSObject for Category and Labeled's NamedGetters are in the right ballpark, whether I'm safe to return nullptr from GetParentObject (and, if not, how I should think about "parent" here).

All in all, I've been finding the docs to be a lovely resource. I just want to make sure I'm not completely off course before I take care of the rest of the interfaces.

Flags: needinfo?(nika)

Clearing the ni? as I've left some comments.

Flags: needinfo?(nika)
Attachment #9349088 - Attachment description: WIP: Bug 1848708 - WIP: Convert Boolean, Counter, Datetime to webidl → WIP: Bug 1848708 - Convert all Glean Metric types to webidl.
Attachment #9349087 - Attachment description: WIP: Bug 1848708 - Move Glean and GleanPings to plain webidl r?nika!,janerik!,perry.mcmanis! → Bug 1848708 - Move Glean and GleanPings to plain webidl r?nika!,janerik!,perry.mcmanis!
Attachment #9349088 - Attachment description: WIP: Bug 1848708 - Convert all Glean Metric types to webidl. → Bug 1848708 - Convert all Glean Metric types to webidl. r?nika!,janerik!,perry.mcmanis!

The severity field is not set for this bug.
:chutten, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(chutten)

Sorry, bugbug, I forgot that one.

Since I'm here, might as well supply an update. I'm working through review comments, hoping to have a new version up for reviewers early-mid next week. Other things, like setting fires in the woods (camping. I was camping for three days), keep taking priority but this is still on my desk.

Severity: -- → S4
Flags: needinfo?(chutten)

chutten: it looks like this patch does not impact Glean metric generation in a way that would directly impact Bug 1852098. Can you confirm? Thanks!

Flags: needinfo?(chutten)

Correct. The scope of this problem is limited to JS modules in non-Chrome contexts, and Use Counters are managed entirely within C++.

Flags: needinfo?(chutten)

Not sure this is the ideal semantics, but it appeases some tests that depend on
the behaviour.

Depends on D187812

Also: add a missing await for testClickResultTelemetry and,
since this is a multiprocess test, ensure we always wait for FOG IPC to flush
before clearing data.

Depends on D187937

See Also: → 1853414
Pushed by chutten@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/726d5138b1d2 Move Glean and GleanPings to plain webidl r=nika,janerik,perry.mcmanis https://hg.mozilla.org/integration/autoland/rev/06061d509ab5 Convert all Glean Metric types to webidl. r=nika,janerik,perry.mcmanis,application-update-reviewers,nalexander https://hg.mozilla.org/integration/autoland/rev/1261ba650483 Glean test methods now return null instead of undefined r=florian,extension-reviewers,rpl https://hg.mozilla.org/integration/autoland/rev/d230a932c850 Corner case for event extra with undefined/null value r=perry.mcmanis,emilio https://hg.mozilla.org/integration/autoland/rev/f1a77753fa0c Update 'new metric type' dev docs for refactor r=perry.mcmanis,janerik https://hg.mozilla.org/integration/autoland/rev/242478709593 testGetValue now returns null not undefined on no value r=pbz https://hg.mozilla.org/integration/autoland/rev/e63a855c0acf testGetValue returns null now r=perry.mcmanis

Ah, non-unified builds are Tier 1 now. Lemme tighten up these includes and try another local build before I resubmit.

Flags: needinfo?(chutten)
Pushed by chutten@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a88fa44abdc9 Move Glean and GleanPings to plain webidl r=nika,janerik,perry.mcmanis https://hg.mozilla.org/integration/autoland/rev/b5f79a977cd5 Convert all Glean Metric types to webidl. r=nika,janerik,perry.mcmanis,application-update-reviewers,nalexander https://hg.mozilla.org/integration/autoland/rev/87d76dd03552 Glean test methods now return null instead of undefined r=florian,extension-reviewers,rpl https://hg.mozilla.org/integration/autoland/rev/074f9e36e8a0 Corner case for event extra with undefined/null value r=perry.mcmanis,emilio https://hg.mozilla.org/integration/autoland/rev/e2c9789f7de1 Update 'new metric type' dev docs for refactor r=perry.mcmanis,janerik https://hg.mozilla.org/integration/autoland/rev/7369ca94287c testGetValue now returns null not undefined on no value r=pbz https://hg.mozilla.org/integration/autoland/rev/d63842cc4cf9 testGetValue returns null now r=perry.mcmanis
Attachment #9349706 - Attachment is obsolete: true
Regressions: 1854731
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: