@@ -987,7 +987,8 @@ class PipelineOwner {
987987 try {
988988 final List <RenderObject > dirtyNodes = _nodesNeedingPaint;
989989 _nodesNeedingPaint = < RenderObject > [];
990- for (final RenderObject node in dirtyNodes..sort ((RenderObject a, RenderObject b) => a.depth - b.depth)) {
990+ // Sort the dirty nodes in reverse order (deepest first).
991+ for (final RenderObject node in dirtyNodes..sort ((RenderObject a, RenderObject b) => b.depth - a.depth)) {
991992 assert (node._layerHandle.layer != null );
992993 if (node._needsPaint && node.owner == this ) {
993994 if (node._layerHandle.layer! .attached) {
@@ -2364,8 +2365,12 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
23642365 return true ;
23652366 }());
23662367 // If we still need layout, then that means that we were skipped in the
2367- // layout phase and therefore don't need painting. This can happen when an
2368- // error occurred prior to our paint and our layer wasn't properly detached.
2368+ // layout phase and therefore don't need painting. We might not know that
2369+ // yet (that is, our layer might not have been detached yet), because the
2370+ // same node that skipped us in layout is above us in the tree (obviously)
2371+ // and therefore may not have had a chance to paint yet (since the tree
2372+ // paints in reverse order). In particular this will happen if they have
2373+ // a different layer, because there's a repaint boundary between us.
23692374 if (_needsLayout)
23702375 return ;
23712376 if (! kReleaseMode && debugProfilePaintsEnabled) {
0 commit comments