unlimitedbacon / stl-thumb-kde

KDE plugin for stl-thumb
MIT License
45 stars 6 forks source link

Error generating thumbnails in Dolphin #5

Open paul opened 1 year ago

paul commented 1 year ago

When I open Dolphin in a folder full of .stl files, a few render thumbnails, but most do not.

image

If I watch the log when I open the folder, it gets filled with error messages like this:

Jun 01 10:47:43 ava.home plasmashell[2788635]: thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/rando/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.3/src/event_loop.rs:106:13
Jun 01 10:47:43 ava.home plasmashell[2788635]: thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/rando/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.3/src/event_loop.rs:106:13
Jun 01 10:47:43 ava.home kioslave5[2788635]: com.stl-thumb-kde: STL-THUMB :: lib returned error
Jun 01 10:47:43 ava.home plasmashell[2788635]: thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/rando/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.3/src/event_loop.rs:106:13
Jun 01 10:47:43 ava.home plasmashell[2788635]: thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/rando/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.3/src/event_loop.rs:106:13
Jun 01 10:47:43 ava.home kioslave5[2788635]: com.stl-thumb-kde: STL-THUMB :: lib returned error
Jun 01 10:47:44 ava.home plasmashell[2788635]: thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/rando/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.3/src/event_loop.rs:106:13
Jun 01 10:47:44 ava.home plasmashell[2788635]: thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/rando/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.3/src/event_loop.rs:106:13
Jun 01 10:47:44 ava.home kioslave5[2788635]: com.stl-thumb-kde: STL-THUMB :: lib returned error

This is using plasmashell 5.27.5 on Fedora 38. It also reports the same error in a folder with only a single .stl file in it.

Not sure if its relevant, I commented out some stuff in create_headless_display and replaced it with context = cb.build_osmesa(size)?; and it logged this the first time, then the same "Creating EventLoop multiple times" after that:

Jun 01 11:00:49 ava.home kioslave5[2792683]: kf.coreaddons: "Could not load plugin from /usr/lib64/qt5/plugins/stlthumbnail.so: Failed to extract plugin meta data from '/usr/lib64/qt5/plugins/stlthumbnail.so'"
Jun 01 11:00:49 ava.home plasmashell[2792683]: thread '<unnamed>' panicked at 'Initializing the event loop outside of the main thread is a significant cross-platform compatibility hazard. If you absolutely need to create an EventLoop on a different thread, you can use the `EventLoopBuilderExtUnix::any_thread` function.', /home/rando/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.3/src/platform_impl/linux/mod.rs:658:13
Jun 01 11:00:49 ava.home plasmashell[2792683]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Jun 01 11:00:49 ava.home kioslave5[2792683]: com.stl-thumb-kde: STL-THUMB :: lib returned error
Jun 01 11:00:57 ava.home plasmashell[2792683]: thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/rando/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.3/src/event_loop.rs:106:13
Jun 01 11:00:57 ava.home kioslave5[2792683]: com.stl-thumb-kde: STL-THUMB :: lib returned error
...
twelho commented 1 year ago

Same issue, with stl-thumb 0.5.0 and stl-thumb-kde 0.4.0 built from source on Fedora 38:

thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.27.3/src/event_loop.rs:106:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'Creating EventLoop multiple times is not supported.', /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.27.3/src/event_loop.rs:106:13
com.stl-thumb-kde: STL-THUMB :: lib returned error

Sometimes when re-entering a directory I get a single additional thumbnail before stl-thumb panics.

alextrical commented 11 months ago

I have noticed similar issues too, but not had chance to look into the cause of the issue. Its something I will be investigating over the holiday

Base OS: Fedora Kinoite 39 Window Manager: Wayland Desktop: KDE

image

alextrical commented 11 months ago

So from what I can tell some of those errors are coming from stl-thumb, but also don't look to be terminal, but could be causing some of the issues of "Running multiple times" as parts are "still attached" image

twelho commented 11 months ago

From what I remember looking into this, the core issue is the following: Dolphin will load stl-thumb-kde into memory once on startup and then call render_to_buffer for every file. render_to_buffer calls render_to_image in a separate thread, which then calls create_headless_display. However, there was a global static OnceCell in place, which prevented creating multiple contexts, even across threads, without unloading and reloading the application, resulting in https://github.com/unlimitedbacon/stl-thumb-kde/issues/5#issuecomment-1656252503. However, it seems like stuff has changed a lot over in glutin/glium land. The currently used version in stl-thumb still has the check in place. Similarly, for the latest glium, one needs to use winit directly for creating the event loop, and the check is still there, however, it is a bit more graceful now.

Ultimately, the correct solution would be to initialize the event loop and graphics context exactly once as the application is initialized, and not for every thumbnail rendering invocation. As a bonus, this should also be faster, since rendering a single thumbnail will not require a full context initialization. Hopefully this helps in the debugging quest!