-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
a: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkf: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusfound in release: 3.19Found to occur in 3.19Found to occur in 3.19frameworkflutter/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 onplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamOwned by Web platform team
Description
Steps to reproduce
flutter channel master && flutter upgrade && flutter create bug --platforms=web- Run the code sample on the master branch, on the web.
flutter run -d chrome - When testing the application, I put the app window on the right and my terminal on the left, so I could see them side-by-side
- When the Flutter app has focus, switch the focus to your terminal window (VSCode, standalone terminal etc)
- The
inactivestate is printed in the terminal (expected) - Press
qin the terminal - The application throws an assertion error (see below)
Expected results
The application lifecycle does not throw an assertion error.
Actual results
An assertion fails (see the logs).
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
print('AppLifecycleState: $state');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: ElevatedButton(
onPressed: () {},
child: const Text('Some button'),
),
),
);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
navaronbracke@MacBook-Pro-van-Navaron web_lifecycle_sample % flutter run -d chrome
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 15.6s
This app is linked to the debug service: ws://127.0.0.1:57998/1bz85YwrHMY=/ws
Debug service listening on ws://127.0.0.1:57998/1bz85YwrHMY=/ws
🔥 To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".
A Dart VM Service on Chrome is available at: http://127.0.0.1:57998/1bz85YwrHMY=
The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:57998/1bz85YwrHMY=
AppLifecycleState: AppLifecycleState.inactive
══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY
╞══════════════════════════════════════════════════════════
The following assertion was thrown during a platform message callback:
Assertion failed:
file:///Users/navaronbracke/Documents/flutter/packages/flutter/lib/src/servic
es/binding.dart:317:12
(){
AppLifecycleState? starting = previousState;
for (final AppLifecycleState ending in stateChanges) {
if (!_debugVerifyLifecycleChange(starting, ending)) {
return false;
}
starting = ending;
}
return true;
}()
"Invalid lifecycle state transition generated from AppLifecycleState.inactive
to
AppLifecycleState.detached (generated [AppLifecycleState.resumed,
AppLifecycleState.detached])"
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 328:3
throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 38:3
assertFailed
packages/flutter/src/services/binding.dart 283:47
_handleLifecycleMessage
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54
runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5
_async
packages/flutter/src/services/binding.dart 281:42
[_handleLifecycleMessage]
packages/flutter/src/services/platform_channel.dart 235:49
<fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54
runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5
_async
packages/flutter/src/services/platform_channel.dart 234:58
<fn>
packages/flutter/src/services/binding.dart 603:35
<fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54
runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5
_async
packages/flutter/src/services/binding.dart 600:98
<fn>
lib/_engine/engine/platform_dispatcher.dart 1381:5
invoke2
lib/ui/channel_buffers.dart 25:12
invoke
lib/ui/channel_buffers.dart 65:7
push
lib/ui/channel_buffers.dart 131:16
push
lib/_engine/engine/platform_dispatcher.dart 425:10
invokeOnPlatformMessage
lib/_engine/engine/platform_dispatcher.dart 1034:5
[_setAppLifecycleState]
lib/_engine/engine/platform_dispatcher/app_lifecycle_state.dart 48:9
onAppLifecycleStateChange
lib/_engine/engine/platform_dispatcher/app_lifecycle_state.dart 94:5
<fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
550:37 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
555:39 dcall
═════════════════════════════════════════════════════════════════════════════
═══════════════════════
AppLifecycleState: AppLifecycleState.hidden
Application finished.Flutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.19.0-9.0.pre.206, on macOS 14.1.2 23B92
darwin-x64, locale en-BE)
• Flutter version 3.19.0-9.0.pre.206 on channel master at
/Users/navaronbracke/Documents/flutter
• Upstream repository [email protected]:navaronbracke/flutter.git
• FLUTTER_GIT_URL = [email protected]:navaronbracke/flutter.git
• Framework revision 7e46394178 (3 hours ago), 2024-01-29 01:46:24 -0500
• Engine revision 210ed1dfb8
• Dart version 3.4.0 (build 3.4.0-82.0.dev)
• DevTools version 2.31.0
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/navaronbracke/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/navaronbracke/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.13.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
17.0.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.85.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.80.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 14.1.2 23B92 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.85
[✓] Network resources
• All expected network resources are available.
• No issues found!
Metadata
Metadata
Assignees
Labels
a: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkf: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusfound in release: 3.19Found to occur in 3.19Found to occur in 3.19frameworkflutter/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 onplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamOwned by Web platform team