未验证 提交 9482a8a1 编写于 作者: M Mouad Debbar 提交者: GitHub

[web] Fix firefox crash during font loading (#25561)

上级 04cd0db0
...@@ -178,7 +178,17 @@ class FontManager { ...@@ -178,7 +178,17 @@ class FontManager {
try { try {
final html.FontFace fontFace = html.FontFace(family, asset, descriptors); final html.FontFace fontFace = html.FontFace(family, asset, descriptors);
_fontLoadingFutures.add(fontFace.load().then((_) { _fontLoadingFutures.add(fontFace.load().then((_) {
html.document.fonts!.add(fontFace); // We could do:
// ```
// html.document.fonts!.add(fontFace);
// ```
// But dart:html expects the return value to be non-null, and Firefox
// returns null. This causes the app to crash in Firefox with a null
// check exception.
//
// TODO(mdebbar): Revert this once the dart:html type is fixed.
// https://github.com/dart-lang/sdk/issues/45676
js_util.callMethod(html.document.fonts!, 'add', [fontFace]);
}, onError: (dynamic e) { }, onError: (dynamic e) {
printWarning('Error while trying to load font family "$family":\n$e'); printWarning('Error while trying to load font family "$family":\n$e');
})); }));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册