Repository navigation
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consoleStack traces logged to the consolef: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusf: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5Found to occur in 3.5frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Hi,
the following snippet causes an assert during focus traversal that a RenderBox has not been laid out (it doesn't have a size).
Repro steps are: click on "Click me", then press tab.
import 'package:flutter/material.dart';
main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
_EditField(),
_Panel(),
],
),
);
}
}
class _EditField extends StatefulWidget {
@override
State<_EditField> createState() => _EditFieldState();
}
class _EditFieldState extends State<_EditField> {
final _focusNode = FocusNode(debugLabel: '_EditField');
@override
Widget build(BuildContext context) {
return TextField(
focusNode: _focusNode,
decoration: const InputDecoration(
contentPadding: EdgeInsets.fromLTRB(12, 18, 12, 18),
filled: true,
hintText: 'Click me',
),
);
}
}
class _Panel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
width: 300.0,
height: 100.0,
child: Navigator(
requestFocus: false,
pages: <MaterialPage<Object>>[
MaterialPage<Object>(name: 'root', child: Container()),
const MaterialPage<Object>(name: 'panel', child: Text('Then press tab')),
],
onPopPage: (_, __) => false,
),
);
}
}Here is the output from the chrome console:
══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
js_primitives.dart:30 The following assertion was thrown while processing the key message handler:
js_primitives.dart:30 Assertion failed: google3:///third_party/dart/flutter/lib/src/rendering/box.dart:2009:12
js_primitives.dart:30 hasSize
js_primitives.dart:30 "RenderBox was not laid out: RenderSemanticsAnnotations#6193f NEEDS-LAYOUT NEEDS-PAINT"
js_primitives.dart:30
js_primitives.dart:30 When the exception was thrown, this was the stack:
js_primitives.dart:30 dart:sdk_internal 5653:11 throw_
js_primitives.dart:30 dart:sdk_internal 5568:15 assertFailed
js_primitives.dart:30 package:flutter/src/rendering/box.dart 2009:12 get size
js_primitives.dart:30 package:flutter/src/rendering/box.dart 2147:44 get semanticBounds
js_primitives.dart:30 package:flutter/src/widgets/focus_manager.dart 796:90 get rect
js_primitives.dart:30 package:flutter/src/widgets/focus_traversal.dart 872:20 new
js_primitives.dart:30 package:flutter/src/widgets/focus_traversal.dart 1115:49 <fn>
js_primitives.dart:30 package:flutter/src/widgets/focus_traversal.dart 1115:75 sortDescendants
js_primitives.dart:30 package:flutter/src/widgets/focus_traversal.dart 333:55 [_sortAllDescendants]
js_primitives.dart:30 package:flutter/src/widgets/focus_traversal.dart 406:41 [_moveFocus]
js_primitives.dart:30 package:flutter/src/widgets/focus_traversal.dart 238:39 next
js_primitives.dart:30 package:flutter/src/widgets/focus_manager.dart 1136:46 nextFocus
js_primitives.dart:30 package:flutter/src/widgets/focus_traversal.dart 1687:5 invoke
js_primitives.dart:30 package:flutter/src/widgets/actions.dart 580:20 invokeAction
js_primitives.dart:30 package:flutter/src/widgets/shortcuts.dart 815:36 handleKeypress
js_primitives.dart:30 package:flutter/src/widgets/shortcuts.dart 999:20 [_handleOnKey]
js_primitives.dart:30 package:flutter/src/widgets/focus_manager.dart 1682:25 [_handleKeyMessage]
js_primitives.dart:30 package:flutter/src/services/hardware_keyboard.dart 897:16 [_dispatchKeyMessage]
js_primitives.dart:30 package:flutter/src/services/hardware_keyboard.dart 962:17 handleRawKeyMessage
js_primitives.dart:30 dart:sdk_internal 42528:34 runBody
js_primitives.dart:30 dart:sdk_internal 42560:7 _async
js_primitives.dart:30 package:flutter/src/services/hardware_keyboard.dart 923:51 handleRawKeyMessage
js_primitives.dart:30 package:flutter/src/services/platform_channel.dart 214:49 <fn>
js_primitives.dart:30 dart:sdk_internal 42528:34 runBody
js_primitives.dart:30 dart:sdk_internal 42560:7 _async
js_primitives.dart:30 package:flutter/src/services/platform_channel.dart 213:58 <fn>
js_primitives.dart:30 package:flutter/src/services/binding.dart 393:35 <fn>
js_primitives.dart:30 dart:sdk_internal 42528:34 runBody
js_primitives.dart:30 dart:sdk_internal 42560:7 _async
js_primitives.dart:30 package:flutter/src/services/binding.dart 390:46 <fn>
js_primitives.dart:30 dart:sdk_internal 228129:7 invoke2
js_primitives.dart:30 dart:sdk_internal 141412:15 invoke
js_primitives.dart:30 dart:sdk_internal 141489:54 push
js_primitives.dart:30 dart:sdk_internal 141587:29 push
js_primitives.dart:30 dart:sdk_internal 198205:27 invokeOnPlatformMessage
js_primitives.dart:30 dart:sdk_internal 200752:49 [_handleHtmlEvent]
js_primitives.dart:30 dart:sdk_internal 200777:29 <fn>
js_primitives.dart:30 dart:sdk_internal 5857:16 _checkAndCall
js_primitives.dart:30 dart:sdk_internal 5862:17 dcall
js_primitives.dart:30 dart:sdk_internal 66501:21 ret
js_primitives.dart:30
js_primitives.dart:30 KeyMessage: KeyMessage([KeyDownEvent#a2d91(physicalKey: PhysicalKeyboardKey#7002b(usbHidUsage:
js_primitives.dart:30 "0x0007002b", debugName: "Tab"), logicalKey: LogicalKeyboardKey#b151c(keyId: "0x100000009",
js_primitives.dart:30 keyLabel: "Tab", debugName: "Tab"), character: null, timeStamp: 0:00:04.291300)])
js_primitives.dart:30 ════════════════════════════════════════════════════════════════════════════════════════════════════
Reacted by Valentin Vignal and Viktor Krechetov
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consoleStack traces logged to the consolef: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusf: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5Found to occur in 3.5frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Activity
danagbemava-nc commentedon Oct 31, 2022
Issue is reproducible using the code sample provided above.
Labeling for further investigation from the team.
logs
flutter doctor -v
justinmc commentedon Nov 4, 2022
@chunhtai Is this a valid use of Navigator? Your name came into my head because of go_router, but let me know if you're not the right person for that question.
chunhtai commentedon Nov 4, 2022
I see no problem using navigator this way. I can't tell why it crash but we should fix it
justinmc commentedon Nov 4, 2022
Thanks, that's what I needed to know. I'll take a closer look at this.
justinmc commentedon Nov 4, 2022
@gspencergoog It looks like the cause of this assertion is that inactive Navigator pages are a part of the focus traversal. So in the repro code (pasted below), the "root" page is not shown, but pressing tab traverses to it. Since it's not laid out, it triggers the assertion.
Does that sound like an accurate assessment to you? I assume the solution would be to exclude inactive pages somewhere?
amin79 commentedon Apr 5, 2024
@saintmac-google Hi. Did you solve you problem?
saintmac-google commentedon Apr 5, 2024
oh that's old.
either that has been solved a while ago or I ended up doing it differently
test: guard nested routers against go_router's shell reports (flutter…