Skip to content

[web] Standardized way to preload emoji font using CanvasKit #78422

@creativecreatorormaybenot

Description

Use case

When using CanvasKit and trying to display emojis, issue #76248 arises, i.e. "Emojis take a few seconds to render on canvaskit".

This means that when first displaying emojis, tofu boxes appear for a few seconds.

Proposal

It would be great to have an exposed function that allows loading the Noto font on app start, so that when the first emojis are displayed, the Noto font is already preloaded.

Workaround

The way we solve this currently is the following:

@override
Widget build(BuildContext build) {
  return Stack(
    children: [
      // w/e
      const Opacity(
        opacity: 0,
        // Insert invisible emoji in order to load the emoji font in CanvasKit
        // on startup. Note that this is a *workaround solution* - we want to
        // find a better one :)
        child: Text('✨'),
      ),
    ],
  );
}

This is inserted on startup. As soon as we actually display emojis, the Noto font has already been downloaded. However, this really feels like a hack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: qualityA truly polished experiencec: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttere: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webengineflutter/engine related. See also e: labels.platform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions