-
Notifications
You must be signed in to change notification settings - Fork 30.2k
compute() doesn't use an isolate in debug mode #150938
Copy link
Copy link
Closed
Labels
r: invalidIssue is closed as not validIssue is closed as not valid
Description
Steps to reproduce
While doing some tests with the compute() function I put a breakpoint inside the function that is passed to compute expecting to see a second call stack when the breakpoint was hit as I have seen when using normal isolates.
Instead I stumbled upon an additional stack frame that I did not expect that pointed to this function:
Future<R> _testCompute<Q, R>(
foundation.ComputeCallback<Q, R> callback, Q message,
{String? debugLabel}) {
if (foundation.kDebugMode) {
final Type? bindingType = foundation.BindingBase.debugBindingType();
if (bindingType.toString() == 'AutomatedTestWidgetsFlutterBinding') {}
}
final FutureOr<R> result = callback(message);
if (result is Future<R>) {
return result;
}
return foundation.SynchronousFuture<R>(result);
}
/// A compute implementation that does not spawn isolates in tests.
const foundation.ComputeImpl compute =
(foundation.kDebugMode || foundation.kIsWeb)
? _testCompute
: foundation.compute;I understand that this might be necessary for tests. However if tests behave differently from the normal app in its timing this too can be problematic.
But it surely shouldn't do this when running a normal app in debug mode or at least if should be controllable by the developer.
Expected results
Use an isolate in debug too
Actual results
see above
Code sample
Code sample
[Paste your code here]Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.22.0, on Microsoft Windows [Version 10.0.19045.4529], locale de-DE)
• Flutter version 3.22.0 on channel stable at C:\Users\escam\fvm\versions\3.22.0
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5dcb86f68f (7 weeks ago), 2024-05-09 07:39:20 -0500
• Engine revision f6344b75dc
• Dart version 3.4.0
• DevTools version 2.34.3
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at C:\Users\escam\AppData\Local\Android\sdk
• Platform android-34, build-tools 33.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.6.2)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.6.33723.286
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2022.2)
• Android Studio at C:\Program Files\Android\Android Studio
• 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-b2043.56-9586694)
[√] VS Code, 64-bit edition (version 1.90.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.90.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.4529]
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.126
• Edge (web) • edge • web-javascript • Microsoft Edge 126.0.2592.68
[√] Network resources
• All expected network resources are available.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
r: invalidIssue is closed as not validIssue is closed as not valid