bitsdojo_window icon indicating copy to clipboard operation
bitsdojo_window copied to clipboard

segfault on Linux within getAppWindowHandle

Open JanezStupar opened this issue 2 years ago • 2 comments

Sometimes the app segfaults on startup.

I managed to trace it to within getAppWindowHandle call.

I can also report that it does not manifest when running with GDB or when running a debug build.

AddressSanitizer reports errors too.

I have neither time nor knowledge to pursue this further. But I can provide more debug information if necessary.

JanezStupar avatar Sep 16 '23 12:09 JanezStupar

An update.

While there may be noncritical leaks... This seems to be some sort of race condition.

The following code helps prevent the crash:

  doWhenWindowReady(() {
    const initialSize = Size(360, 720);
    appWindow.minSize = initialSize;
    appWindow.size = initialSize;
    appWindow.alignment = Alignment.center;
    sleep(Duration(milliseconds: 100)); // This buys enough time to prevent crash
    appWindow.show();
  });

JanezStupar avatar Sep 18 '23 08:09 JanezStupar

Closed the issue too soon when testing it turns out that I built the app in debug mode.

Apparently this helps mitigate the race condition too:

  runApp(MyApp(locale));
  doWhenWindowReady(() {
    const initialSize = Size(360, 720);
    appWindow.minSize = initialSize;
    appWindow.size = initialSize;
    appWindow.alignment = Alignment.center;
    appWindow.show();
  });
  sleep(Duration(milliseconds: 10));

JanezStupar avatar Sep 18 '23 10:09 JanezStupar