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

fix: fix loading fonts cause assertion when remove or attach RenderObjects. #425

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

andycall
Copy link
Member

In Flutter 3.10, they had add checks for the fonts in loading stage when attach or detach RenderObjects on RenderObject tree.

We needs to delay the font loading to the end of frame to make sure renderObjects are not mutated at that times.

  @override
  void attach(PipelineOwner owner) {
    super.attach(owner);
    // If there's a pending callback that would imply this node was detached
    // between the idle phase and the next transientCallbacks phase. The tree
    // can not be mutated between those two phases so that should never happen.
    assert(!_hasPendingSystemFontsDidChangeCallBack);
    PaintingBinding.instance.systemFonts.addListener(_scheduleSystemFontsUpdate);
  }

  @override
  void detach() {
    assert(!_hasPendingSystemFontsDidChangeCallBack);
    PaintingBinding.instance.systemFonts.removeListener(_scheduleSystemFontsUpdate);
    super.detach();
  }

@yifei8 yifei8 added this pull request to the merge queue Jul 20, 2023
Merged via the queue into main with commit 3792844 Jul 20, 2023
24 checks passed
@yifei8 yifei8 deleted the fix/font_loading branch July 20, 2023 03:25
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

Successfully merging this pull request may close these issues.

None yet

3 participants