Skip to content

Optimize unneeded rebuild when pushing overlay/navigator opaque content #45797

@rrousselGit

Description

@rrousselGit

Internal: b/146212303

Related to: #11655

Currently, there's an optimization performed by Navigator/Overlay such that when a full-screen opaque content is placed above another content, the content behind will stop painting.

It is useful, but at the same time there's an irony:
The act of flagging the previously visible widget tree as no longer needing to be painted forces the entire associated widget tree to rebuild.

From my understanding, this is caused by a change in the depth of the associated widget tree during the transition. This, therefore, cause the widget tree to be deactivated and reactivated for a frame, which calls build/didChangeDependencies on everything.

It is suboptimal, especially considering the widget tree is actually no longer visible.

My theory is that is should be possible to fix this inconvenience by a change on this line

by changing it from:

_Theatre(
  onstage: Stack(
    fit: StackFit.expand,
    children: onstageChildren.reversed.toList(growable: false),
  ),
  offstage: offstageChildren,
);

to:

_Theatre(
  // somehow make _RenderTheatre fill the gap of the missing Stack
  onstage: onstageChildren.reversed.toList(growable: false),
  offstage: offstageChildren,
);

This should remove the reparenting, which should no longer unnecessarily rebuild the no longer visible widget tree.

Metadata

Metadata

Assignees

Labels

c: performanceRelates to speed or footprint issues (see "perf:" labels)c: proposalA detailed proposal for a change to Flutterf: routesNavigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.perf: speedPerformance issues related to (mostly rendering) speed

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions