From dca7480bd3f9acdffa8ac2dffc94c2845b8bd6e2 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Wed, 20 Sep 2017 14:17:50 -0700 Subject: [PATCH] Don't crash on iOS if there is only a single SemanticsNode (flutter/engine#4128) * Don't crash if there is only a single SemanticsNode Previously, the code assumed that the root SemanticsNode will allways have a child. This is not true as can be seen in the hello_world example app, which would crash when a11y is turned on. * review comment --- .../darwin/ios/framework/Source/accessibility_bridge.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index 06135d426c..9953ebdf57 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -206,11 +206,12 @@ bool GeometryComparator(SemanticsObject* a, SemanticsObject* b) { #pragma mark - UIAccessibilityElement protocol - (id)accessibilityContainer { - if ([self hasChildren]) { + if ([self hasChildren] || _uid == kRootNodeId) { if (_container == nil) _container = [[SemanticsObjectContainer alloc] initWithSemanticsObject:self bridge:_bridge]; return _container; } + NSAssert(_parent != nil, @"Illegal access to non-existent parent of root semantics node"); return [_parent accessibilityContainer]; }