NS_ERROR_FAILURE in Firefox 105, when .fillText is called on canvas's context, inside element with shadow DOM
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox114 | --- | fixed |
People
(Reporter: github, Assigned: emilio)
References
Details
Attachments
(3 files)
Steps to reproduce:
- Generate Ionic + Angular project
- Create canvas element inside ion-content element, in the Ionic Page
- Add selector (e.g. #canva) to the canvas element
- Query the element by Angular's ViewChild
- Get 2d context in Angular's ngAfterViewInit
- Call .flllText('hello, world', 10, 10) on 2d context
Expected: hello, world is visible
Actual: An error is thrown
(stackblitz: https://stackblitz.com/edit/angular-ivy-pyvhyk?file=src/app/pages/index/index.page.ts, I couldn't find proper reproduction steps which wouldn't use Ionic)
Related issues with libraries:
Ionic: https://github.com/ionic-team/ionic-framework/issues/26039
Chart.js: https://github.com/chartjs/Chart.js/issues/10720
Actual results:
If one would like to write a text using .fillText, or even change font styling by using .font in the canvas element, it results in NS_ERROR_FAILURE.
Expected results:
Text-related actions on canvas 2d context should not throw an error
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Graphics: Canvas2D' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•3 years ago
|
||
I am seeing this same error within an Angular & ionic app but with amchart tooltip text instead.
Comment 3•3 years ago
|
||
I was able to reproduce the issue outside of Ionic. The reported issue appears when trying to draw on a canvas passed to a Shadow DOM custom element that does not have a <slot>.
- Open attached code reproduction in Firefox 105+.
- Open developer tools.
- In the "Inspector" tab observe that there is a
<canvas>element inside of a custom element named<my-cmp>. - Observe that the reported error is in the console.
- In the custom element constructor, add
root.innerHTML = '<slot></slot>';. - Reload the page. Observe that the error is no longer present and the canvas is drawn correctly.
This issue was happening in Ionic because Stencil, the Web Component compiler that Ionic uses, was adding the <slot> asynchronously. As a result, there was a period where the custom element had been upgraded to use the Shadow DOM, but the component's slot had not yet been added to the DOM.
Comment 4•3 years ago
|
||
The severity field is not set for this bug.
:lsalzman, could you have a look please?
For more information, please visit auto_nag documentation.
Updated•3 years ago
|
Updated•3 years ago
|
Comment 6•3 years ago
|
||
When could one expect that this bug will be fixed? There is no Priority set.
Comment 7•2 years ago
|
||
This happens because we up checking the pref layout.css.computed-style.styles-outside-flat-tree via nsComputedDOMStyle::GetComputedStyle. That was introduced quite intentionally it seems in bug 1483798. Emilio is that behavior expected?
| Assignee | ||
Comment 8•2 years ago
|
||
Yes, there's no style for those elements per spec, but we shouldn't throw.
| Assignee | ||
Comment 9•2 years ago
|
||
When an element is out of the flat tree we should treat it the same as
when it is out of the document, it has no meaningful style.
Updated•2 years ago
|
Comment 10•2 years ago
|
||
Comment 12•2 years ago
|
||
Comment 13•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/0dd4dda463cb
https://hg.mozilla.org/mozilla-central/rev/51ca4e1f0f46
Updated•2 years ago
|
Description
•