google / flutter-desktop-embedding

Experimental plugins for Flutter for Desktop
Apache License 2.0
7.1k stars 604 forks source link

[file_selector_linux] Crash when open select file dialog #868

Closed friebetill closed 2 years ago

friebetill commented 3 years ago

Describe the bug The example app crashes as soon as I try to open a file on Ubuntu 20.04.

Unfortunately, there is no error message, see the attached video: https://user-images.githubusercontent.com/10923085/126900816-89df2ed3-0f85-4a46-a163-829d6b377ffd.mp4

Unfortunately, I don't know how to debug the C++ code either.

Doctor Output Please provide the output of flutter doctor -v:

[✓] Flutter (Channel stable, 2.2.3, on Linux, locale en_US.UTF-8)
    • Flutter version 2.2.3 at /home/max/Desktop/Till/flutter
    • Framework revision f4abaa0735 (3 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for
      detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for
      detailed instructions).

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Linux

! Doctor found issues in 3 categories.
stuartmorgan commented 3 years ago

Please run the debug binary under lldb or gdb and provide a stack trace for the crash.

alann-maulana commented 3 years ago

Yeah I got the crash too when open file dialog in Ubuntu 18.04.5, here is my log when running debug app under lldb :

(lldb) process launch
Process 20709 launched: '/projects/flutter_plugins/example/build/linux/x64/debug/bundle/example' (x86_64)
flutter: Observatory listening on http://127.0.0.1:38175/tx72RvwUwz0=/
[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
example: ../../src/xcb_io.c:639: _XReply: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Process 20709 stopped
* thread #1, name = 'example', stop reason = signal SIGABRT
    frame #0: 0x00007ffff2652fb7 libc.so.6`__GI_raise(sig=2) at raise.c:51
stuartmorgan commented 3 years ago

What is the stack for that abort call?

friebetill commented 3 years ago

The crash doesn't occur when I run plugins/file_selector/example/build/linux/x64/debug/bundle/example with

It also doesn't crash when I start the program with

It only crashes when I start the example via VSCode.

alann-maulana commented 3 years ago

What is the stack for that abort call?

Do you mean call stack?

Call stack lldb ``` (lldb) bt * thread #4, name = 'io.flutter.io', stop reason = signal SIGABRT * frame #0: 0x00007ffff2652fb7 libc.so.6`__GI_raise(sig=2) at raise.c:51 frame #1: 0x00007ffff2654921 libc.so.6`__GI_abort at abort.c:79 frame #2: 0x00007ffff264448a libc.so.6`__assert_fail_base(fmt="%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion="!xcb_xlib_threads_sequence_lost", file="../../src/xcb_io.c", line=639, function=) at assert.c:92 frame #3: 0x00007ffff2644502 libc.so.6`__GI___assert_fail(assertion=, file=, line=, function=) at assert.c:101 frame #4: 0x00007ffff1af6b39 libX11.so.6`_XReply + 1161 frame #5: 0x00007fffe8046f5a libGL.so.1`___lldb_unnamed_symbol20$$libGL.so.1 + 378 frame #6: 0x00007fffe1e53998 libPrlDRI.so.1`CGLContext::CallHost(unsigned int, void*, unsigned long, void*, unsigned long) + 600 frame #7: 0x00007fffe1e0b3b4 libPrlDRI.so.1`___lldb_unnamed_symbol277$$libPrlDRI.so.1 + 244 frame #8: 0x00007ffff507e02f libflutter_linux_gtk.so`GrGLGpu::createTexture(SkISize, GrGLFormat, unsigned int, GrRenderable, GrGLTextureParameters::SamplerOverriddenState*, int) + 1071 frame #9: 0x00007ffff507d703 libflutter_linux_gtk.so`GrGLGpu::onCreateTexture(SkISize, GrBackendFormat const&, GrRenderable, int, SkBudgeted, GrProtected, int, unsigned int) + 195 frame #10: 0x00007ffff4f8050d libflutter_linux_gtk.so`GrGpu::createTextureCommon(SkISize, GrBackendFormat const&, GrRenderable, int, SkBudgeted, GrProtected, int, unsigned int) + 221 frame #11: 0x00007ffff4f80a4c libflutter_linux_gtk.so`GrGpu::createTexture(SkISize, GrBackendFormat const&, GrRenderable, int, SkBudgeted, GrProtected, GrColorType, GrColorType, GrMipLevel const*, int) + 1036 frame #12: 0x00007ffff4f96c13 libflutter_linux_gtk.so`GrResourceProvider::createTexture(SkISize, GrBackendFormat const&, GrColorType, GrRenderable, int, SkBudgeted, GrMipmapped, GrProtected, GrMipLevel const*) + 595 frame #13: 0x00007ffff4f8e192 libflutter_linux_gtk.so`std::__1::__function::__func, GrSurfaceProxy::LazyCallbackResult (GrResourceProvider*, GrSurfaceProxy::LazySurfaceDesc const&)>::operator()(GrResourceProvider*&&, GrSurfaceProxy::LazySurfaceDesc const&) + 402 frame #14: 0x00007ffff4fafa1f libflutter_linux_gtk.so`GrSurfaceProxyPriv::doLazyInstantiation(GrResourceProvider*) + 143 frame #15: 0x00007ffff4f8caaf libflutter_linux_gtk.so`GrProxyProvider::createProxyFromBitmap(SkBitmap const&, GrMipmapped, SkBackingFit, SkBudgeted) + 351 frame #16: 0x00007ffff4f61ddf libflutter_linux_gtk.so`GrBitmapTextureMaker::refOriginalTextureProxyView(GrMipmapped) + 255 frame #17: 0x00007ffff4fb088e libflutter_linux_gtk.so`GrTextureMaker::onView(GrMipmapped) + 94 frame #18: 0x00007ffff4fb0e2f libflutter_linux_gtk.so`GrTextureProducer::view(GrMipmapped) + 63 frame #19: 0x00007ffff5055696 libflutter_linux_gtk.so`SkImage::MakeCrossContextFromPixmap(GrDirectContext*, SkPixmap const&, bool, bool) + 486 frame #20: 0x00007ffff5245e99 libflutter_linux_gtk.so`std::__1::__function::__func, fml::WeakPtr, fml::tracing::TraceFlow const&)::$_3, std::__1::allocator, fml::WeakPtr, fml::tracing::TraceFlow const&)::$_3>, void ()>::operator()() + 121 frame #21: 0x00007ffff4cc01b4 libflutter_linux_gtk.so`fml::SyncSwitch::Execute(fml::SyncSwitch::Handlers const&) const + 36 frame #22: 0x00007ffff5245857 libflutter_linux_gtk.so`std::__1::__function::__func, unsigned int, unsigned int, std::__1::function)> const&)::$_1::operator()()::'lambda'()>, std::__1::allocator, unsigned int, unsigned int, std::__1::function)> const&)::$_1::operator()()::'lambda'()> >, void ()>::operator()() + 2167 frame #23: 0x00007ffff4cbb75f libflutter_linux_gtk.so`fml::MessageLoopImpl::FlushTasks(fml::FlushType) + 255 frame #24: 0x00007ffff4cc20e6 libflutter_linux_gtk.so`fml::MessageLoopLinux::Run() + 134 frame #25: 0x00007ffff4cbb611 libflutter_linux_gtk.so`fml::MessageLoopImpl::DoRun() + 17 frame #26: 0x00007ffff4cc0995 libflutter_linux_gtk.so`void* std::__1::__thread_proxy >, fml::Thread::Thread(std::__1::basic_string, std::__1::allocator > const&)::$_0> >(void*) + 261 frame #27: 0x00007ffff742c6db libpthread.so.0`start_thread + 219 frame #28: 0x00007ffff273571f libc.so.6`__GI___clone at clone.S:95 ```
stuartmorgan commented 3 years ago

I'm not able to reproduce this. Is it a regression from an earlier version of Flutter, or has this never worked for you?

@robert-ancell Any thoughts about the thread abort logging (assuming that's indeed the abort that's in the stack)?

alann-maulana commented 3 years ago

Just in case this will helps, actually I'm running this example project app on Linux (Ubuntu 18.04.5) but crash after select a file. But it's doing ok while running on MacOS and Windows.

Flutter doctor ``` [✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_US.UTF-8) [✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use `flutter config --android-sdk` to update to that location. [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Linux toolchain - develop for Linux desktop [!] Android Studio (not installed) [✓] Connected device (1 available) ! Doctor found issues in 3 categories. ```
hostnamectl ``` Static hostname: macbook-pro Pretty hostname: MacBook-Pro Icon name: computer-vm Chassis: vm Machine ID: 871927a6b3a046489a5d1f7281e15f8a Boot ID: fc55c7f2eaba4d268969a2b09b57f129 Virtualization: kvm Operating System: Ubuntu 18.04.5 LTS Kernel: Linux 5.4.0-42-generic Architecture: x86-64 ```
friebetill commented 3 years ago

I'm not able to reproduce this. Is it a regression from an earlier version of Flutter, or has this never worked for you?

I've been using the library for three weeks (so only with Flutter 2.2.3) and the Linux part didn't work for me from the beginning.

GroovinChip commented 2 years ago

Hello, I am also running into problems with file_selector_linux crashing when doing file choosing and saving operations. I've prepared reproduction sample code:

import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'File Selector Bug',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              child: const Text('Upload File'),
              onPressed: () async {
                final bytes = await openFiles();
                debugPrint('${bytes.length}');
              },
            ),
          ],
        ),
      ),
    );
  }
}

The crash occurs every time the program is run via IDE. Interestingly, when debugging this reproduction via gdb, the crash does not occur.

I ran my original program through gdb to see if I could reproduce the crash, and the only error message I was able to get was

terminate called without an active exception
--Type <RET> for more, q to quit, c to continue without paging--c

Thread 1 "example" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

I hope this is helpful for solving this issue.

GroovinChip commented 2 years ago

Thought it was worth mentioning that I figured out the problem - I was using the snap store version of Flutter. Switching to the regular version solved the issue completely.

stuartmorgan commented 2 years ago

Closing, as this plugin has moved to flutter/plugins.

If anyone can still reproduce this in a current version please file an issue in https://github.com/flutter/flutter/issues, or if (per the last comment) it's snap-only, in https://github.com/canonical/flutter-snap