• Michael Goderbauer's avatar
    Fixes crash caused by invisible semantics children (#13740) · 4e13cd07
    Michael Goderbauer authored
    **tl;dr:** A `RenderObject` can only be an effective semantics boundary if it actually owned a `SemanticsNode` in the previous tree generation.
    
    When using the `BlockSemantics` widget it is possible to introduce `RenderObject`s that are configured to be a semantics boundary, but because their semantics are blocked by `BlockSemantics` they will not (immediately) end up owning a `SemanticsNode`. When now a descendant of such a node-less semantics boundary marks itself as needing a semantics update we walk up the tree until we find the closest semantics boundary (which is our node-less `RenderObject`). We now incorrectly assume that this semantics boundary has a valid `SemanticsNode` and only regenerate the semantics subtree below this node. However, because the identified semantics boundary doesn't actually own a valid `SemanticsNode` asserts are throwing (e.g. `Child with id xx is invisible and should not be added to tree.`).
    
    To fix this problem, we can just abort the walk if we reach a semantics boundary without a semantics node because (for now) we know that the semantics information of this branch will not make it into the final semantics tree.
    If the semantics block is ever removed, the current algorithm re-generates the semantics for the entire branch and the semantics will be up-to-date then despite the abort. I've added a test to verify this to make sure it continues to work even when we change the algorithm.
    
    Fixes https://github.com/flutter/flutter/issues/13326.
    /cc @gavindoughtie FYI
    4e13cd07
object.dart 126 KB