-
Notifications
You must be signed in to change notification settings - Fork 28.6k
App freezes spawning a Process
from Mac desktop app on M1
#95805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @blahblab, Thanks for filing the issue. I am able to reproduce the issue. When running the below code sample on stable 2.8.1 the app lags after incrementing the counter couple of times while it works fine on
code sampleimport 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
for (int i = 0; i < _counter; i++) {
Timer(Duration(seconds: i), () {
print(" This line is execute after $i seconds");
var result = Process.start('ls', [
'-l',
]);
print(" $i $result");
});
print("complete iteration");
}
print("complete Run");
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
} flutter doctor -v (stable/master)
flutter doctor -v (stable 2.5.3)
stable 2.5.3 logs
master logs
|
I'm also pretty sure this happens on Windows 11 PC also. |
I did verify on ubuntu |
Oh this is interesting, I ran a Release version of the build today (still through Android Studio on same MacOS system) and that seems to work fine? |
Yes, I can confirm this, This issue seems to be only in debug mode and works fine in release mode. |
Does the outcome change if you wait on the Future and get the process result? Make sure you check out the docs for Process.start: it's a little tricky when it comes to how 8000 it is used. Waiting on stderr and stdout to complete is basically required to avoid leaking resources. |
It does not make a difference if I await. |
Just another data point, I tried running the following plain Dart script on my Mac, and it runs just fine without hanging, so it does have an interaction with Flutter somehow: import 'dart:async';
import 'dart:io';
void main(List<String> args) {
for (int i = 0; i < 10; i++) {
Timer(Duration(seconds: i), () {
print(" This line is executed after $i seconds");
var result = Process.start('ls', ['-l']);
print(" $i $result");
});
print("complete iteration");
}
} |
I cannot reproduce this on Linux or macOS on the master branch. I pressed the button 20 times in rapid succession, and it didn't lock up, and printed all the expected output. flutter doctor -v[✓] Flutter (Channel unknown, 2.9.0-1.0.pre.299, on macOS 12.1 21C52 darwin-x64, locale en) • Flutter version 2.9.0-1.0.pre.299 at /Users/gspencer/code/flutter • Upstream repository unknown • Framework revision 098721e341 (7 hours ago), 2022-01-10 05:40:18 -0500 • Engine revision 6a9c04dc47 • Dart version 2.16.0 (build 2.16.0-144.0.dev) • DevTools version 2.9.2 |
(sorry, accidentally hit "close") I was also unable to reproduce this on the stable branch on macOS as well:
@blahblab and @maheshmnj Can you think of anything that might be different about your setup, or more detail about how to reproduce it? Did you hit the "+" button in rapid succession, or slowly? It looks like it hangs right away when you press it: is that the case? My method was to click the "+" 20 times in rapid succession. |
@gspencergoog It seems that the issue mostly, or even exclusively, affects darwin-arm (M1 Macs). Judging from your logs you're on an Intel Mac. @blahblab and @maheshmnj both have darwin-arm in their logs and so do I, and I can reproduce it consistently, also on |
OK, thanks, that's a good data point. Thanks for giving me a good reason to order an M1. :-) |
Process
from Mac desktop app on M1, Sandbox: ls(4387) deny(1) mach-lookup com.apple.oahdProcess
from Mac desktop app on M1, Sandbox: ls(4387) deny(1) mach-lookup com.apple.oahd
Never mind, Bisected to #92313 / flutter/engine#29292 |
Process
from Mac desktop app on M1, Sandbox: ls(4387) deny(1) mach-lookup com.apple.oahdProcess
from Mac desktop app on M1
In that Dart roll, I'm seeing the change to switch the way the sampling CPU profiler works (https://dart.googlesource.com/sdk.git/+/db45ae178a71c4df41ceec3c28c6d562dedc132f). Does this happen in a |
/cc @bkonyi |
None of us on the VM team have consistent access to an M1 device, but @rmacnak-google will take a look once his arrives (could be a month or so). |
@zanderso it doesn't happen in a release build:
|
yeah as the op I can confirm that my workaround is to use release build |
Hi folks, was there ever a resolution to this bug? Thanks! |
I'm unable to reproduce this on |
I am finally able to get outputs from stdout correctly now in debug mode, thank you flutter team |
@cbracken I can still reproduce this issue in version 3.0.2.
import 'dart:io';
import 'package:test/test.dart';
void main() {
test('Process.run', () async {
for (var i = 0; i < 100; i++) {
// Idem with Process.runSync
await Process.run('ls', []);
print('Run $i');
}
});
}
Run Run
|
@xvrh thanks, I can repro in |
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. |
@cbracken can we re-open this ticket? |
Reopening since this was reproducible on the secondary triage #95805 (comment) |
@a-wallen Thanks! I confirm it works correctly on |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
This used to work some three months ago. I have abstracted the issue out of my code (my actual code is making numerous Curl calls using this format, and I've tried both sync and async, with and without awaits. I abstracted this snippet out to replicate. It just hangs and has to be restarted. There is no output even using verbose.
Steps to Reproduce
Embed this in the _demo Flutter app _MyHomePageState and press the button a few times. _
Logs
The text was updated successfully, but these errors were encountered: