Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web renderer breaks when dom.textMetrics.fontBoundingBox is disabled #842

Open
themmj opened this issue Oct 3, 2024 · 0 comments
Open

Comments

@themmj
Copy link

themmj commented Oct 3, 2024

Symptom:
A blank page after the initial loading screen with
Uncaught TypeError: CanvasRenderingContext2D.createLinearGradient: Argument 2 is not a finite floating-point value.
in the console.

Steps to reproduce
Using Waterfox as the browser, open https://one.livesplit.org/
Alternatively, disable dom.textMetrics.fontBoundingBox.enabled in about:config and open https://one.livesplit.org/

Root cause
CanvasFont's top and bottom attribute are determined by TextMetrics.fontBoundingBoxAscend/Descend.
This is an experimental feature that is disabled by default for some browsers (e.g. Waterfox). If they are disabled, the Javascript-Structure for TextMetrics does not contain fontBoundingBoxAscend/Descend properties.
As a result top and bottom are populated with NaNs. These values are eventually used to set the y-bounds on a CanvasLabel which will be passed to createLinearGradient.

Workaround
Set dom.textMetrics.fontBoundingBox.enabled in about:config to true.

Comments
The easiest solution would be to set top and bottom to 0 if they are NaN. Optionally, fall back on actualBoundingBoxAscend/Descend beforehand which seem to be enabled by default on a lot more browsers. The FIXME above these calls suggests that it shouldn't be done like that anyway. Let me know if I should proceed with the simple fix as a PR or if a more elaborate fix is preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant