Skip to content
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

[bug] Linux Gnome calls the get_file_icon method with an error. #17

Open
ayangweb opened this issue Dec 13, 2024 · 12 comments
Open

[bug] Linux Gnome calls the get_file_icon method with an error. #17

ayangweb opened this issue Dec 13, 2024 · 12 comments

Comments

@ayangweb
Copy link

Hey👋, excuse me, I am getting error while using get_file_icon in linux Gnome, how should I fix it, thanks for the help!

image
@IohannRabeson
Copy link
Owner

As the message suggest, it seems not possible to call GTK functions if not in the main thread.
Can you show me the backtrace?

@ayangweb
Copy link
Author

I started the project with RUST_BACKTRACE=1 pnpm tauri dev and reported the following error!

thread 'tokio-runtime-worker' panicked at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gtk-0.18.2/src/auto/icon_theme.rs:35:9:
GTK may only be used from the main thread.
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:74:14
   2: gtk::auto::icon_theme::IconTheme::default
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gtk-0.18.2/src/rt.rs:23:17
   3: file_icon_provider::implementation::get_file_icon
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/file_icon_provider-0.3.1/src/lib.rs:272:30
   4: file_icon_provider::get_file_icon
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/file_icon_provider-0.3.1/src/lib.rs:76:5
   5: tauri_plugin_fs_pro::commands::icon::{{closure}}
             at /home/parallels/Documents/tauri-plugin-fs-pro/src/commands.rs:244:16
   6: <F as futures_core::future::TryFuture>::try_poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-core-0.3.31/src/future.rs:92:9
   7: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.31/src/future/try_future/into_future.rs:34:9
   8: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.31/src/future/future/map.rs:55:37
   9: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.31/src/lib.rs:86:13
  10: <futures_util::future::try_future::MapErr<Fut,F> as core::future::future::Future>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.31/src/lib.rs:86:13
  11: <futures_util::future::try_future::ErrInto<Fut,E> as core::future::future::Future>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.31/src/lib.rs:86:13
  12: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.31/src/future/future/map.rs:55:37
  13: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.31/src/lib.rs:86:13
  14: tauri_plugin_fs_pro::init::{{closure}}::{{closure}}
             at /home/parallels/Documents/tauri-plugin-fs-pro/src/lib.rs:12:25
  15: tauri::ipc::InvokeResolver<R>::respond_async_serialized::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-2.1.1/src/ipc/mod.rs:343:33
  16: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/core.rs:331:17
  17: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/loom/std/unsafe_cell.rs:16:9
  18: tokio::runtime::task::core::Core<T,S>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/core.rs:320:13
  19: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/harness.rs:499:19
  20: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
  21: std::panicking::try::do_call
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40
  22: __rust_try
  23: std::panicking::try
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19
  24: std::panic::catch_unwind
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14
  25: tokio::runtime::task::harness::poll_future
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/harness.rs:487:18
  26: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/harness.rs:209:27
  27: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/harness.rs:154:15
  28: tokio::runtime::task::raw::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/raw.rs:271:5
  29: tokio::runtime::task::raw::RawTask::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/raw.rs:201:18
  30: tokio::runtime::task::LocalNotified<S>::run
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/mod.rs:435:9
  31: tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/scheduler/multi_thread/worker.rs:596:13
  32: tokio::runtime::coop::with_budget
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/coop.rs:107:5
  33: tokio::runtime::coop::budget
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/coop.rs:73:5
  34: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/scheduler/multi_thread/worker.rs:595:9
  35: tokio::runtime::scheduler::multi_thread::worker::Context::run
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/scheduler/multi_thread/worker.rs:546:24
  36: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/scheduler/multi_thread/worker.rs:511:21
  37: tokio::runtime::context::scoped::Scoped<T>::set
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/context/scoped.rs:40:9
  38: tokio::runtime::context::set_scheduler::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/context.rs:180:26
  39: std::thread::local::LocalKey<T>::try_with
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:283:12
  40: std::thread::local::LocalKey<T>::with
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:260:9
  41: tokio::runtime::context::set_scheduler
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/context.rs:180:9
  42: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/scheduler/multi_thread/worker.rs:506:9
  43: tokio::runtime::context::runtime::enter_runtime
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/context/runtime.rs:65:16
  44: tokio::runtime::scheduler::multi_thread::worker::run
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/scheduler/multi_thread/worker.rs:498:5
  45: tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/scheduler/multi_thread/worker.rs:464:45
  46: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/blocking/task.rs:42:21
  47: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/core.rs:331:17
  48: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/loom/std/unsafe_cell.rs:16:9
  49: tokio::runtime::task::core::Core<T,S>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/core.rs:320:13
  50: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/harness.rs:499:19
  51: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
  52: std::panicking::try::do_call
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40
  53: __rust_try
  54: std::panicking::try
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19
  55: std::panic::catch_unwind
             at /home/parallels/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14
  56: tokio::runtime::task::harness::poll_future
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/harness.rs:487:18
  57: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/harness.rs:209:27
  58: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/harness.rs:154:15
  59: tokio::runtime::task::raw::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/raw.rs:271:5
  60: tokio::runtime::task::raw::RawTask::poll
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/raw.rs:201:18
  61: tokio::runtime::task::UnownedTask<S>::run
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/task/mod.rs:472:9
  62: tokio::runtime::blocking::pool::Task::run
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/blocking/pool.rs:161:9
  63: tokio::runtime::blocking::pool::Inner::run
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/blocking/pool.rs:511:17
  64: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /home/parallels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.42.0/src/runtime/blocking/pool.rs:469:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@IohannRabeson
Copy link
Owner

I'm afraid the only solution is to call get_file_icon from the main thread on linux

@ayangweb
Copy link
Author

So should I solve this problem by myself?

@IohannRabeson
Copy link
Owner

Pull requests are welcome

@IohannRabeson
Copy link
Owner

IohannRabeson commented Dec 21, 2024

Well it catched my interest, I might come with a solution.
That might also open the way to the support for other desktops than Gnome.

@IohannRabeson
Copy link
Owner

@ayangweb Can you provide a minimal example that reproduce your issue?

@ayangweb
Copy link
Author

@IohannRabeson
Copy link
Owner

IohannRabeson commented Dec 23, 2024

That does not seems minimal to me.. Without an example i will not be able to fix your issue.

@ayangweb
Copy link
Author

Then I'm not available these days, I'm busy with work!

@IohannRabeson
Copy link
Owner

That fine, for my use case I have no issues on my end so I can wait, but my interest might be attracted by something else.

@ayangweb
Copy link
Author

Hey, sorry, I've been busy lately. When you have time, try the demo below!

https://github.com/ayangweb/file-icon-provider-demo

iShot_2024-12-27_14.45.13.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants