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

Using windows task scheduler to start app, sometimes an error occurs #171

Open
hanaTsuk1 opened this issue Jun 23, 2024 · 8 comments
Open

Comments

@hanaTsuk1
Copy link

hanaTsuk1 commented Jun 23, 2024

I need the app to run as admin by default when autostart, so I use task scheduler to do this
But sometimes an error message appears
Tray(OsError(Os { code: -2147467259, kind: Uncategorized, message: "未指定的错误" }))


builder
  .setup(|app| {
    let result = TrayIconBuilder::with_id("tray")
           .icon(app.default_window_icon().unwrap().clone())
           .build(app);
  })
name = "tray-icon"
version = "0.13.4"
@amrbashir
Copy link
Member

The error is Uncategorized which is not helpful at all, do you think you could get a backtrace?

@hanaTsuk1
Copy link
Author

Please tell me how to modify the code to get a backtrace

@amrbashir
Copy link
Member

maybe try calling .unwrap() on .build() of TrayIconBuilder

@hanaTsuk1
Copy link
Author

I need to test when my computer starts. Is it okay to use 'log::trace'

@amrbashir
Copy link
Member

just a plain println! should work as long as you compile your application in debug mode so you have access to the console.

@hanaTsuk1
Copy link
Author

Sorry, it took some time
Is the following information what you need?

thread 'main' panicked at src\lib.rs:194:33:
called `Result::unwrap()` on an `Err` value: Tray(OsError(Os { code: -2147467259, kind: Uncategorized, message: "未指定 的错误" }))
stack backtrace:
   0:     0x7ff60d151f52 - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\sys_common\backtrace.rs:44
   1:     0x7ff60d17835d - core::fmt::rt::Argument::fmt
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\fmt\rt.rs:142
   2:     0x7ff60d17835d - core::fmt::write
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\fmt\mod.rs:1120
   3:     0x7ff60d14ce61 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\io\mod.rs:1846
   4:     0x7ff60d151d7a - std::sys_common::backtrace::_print
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\sys_common\backtrace.rs:47
   5:     0x7ff60d151d7a - std::sys_common::backtrace::print
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\sys_common\backtrace.rs:34
   6:     0x7ff60d154439 - std::panicking::default_hook::closure$1
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:272
   7:     0x7ff60d1540f5 - std::panicking::default_hook
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:292
   8:     0x7ff60d154954 - std::panicking::rust_panic_with_hook
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:781
   9:     0x7ff60d154829 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:659
  10:     0x7ff60d152859 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\sys_common\backtrace.rs:171
  11:     0x7ff60d1544f6 - std::panicking::begin_panic_handler
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:647
  12:     0x7ff60d3af187 - core::panicking::panic_fmt
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\panicking.rs:72
  13:     0x7ff60d3af7c3 - core::result::unwrap_failed
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\result.rs:1649
  14:     0x7ff60b571ef0 - enum2$<core::result::Result<tauri::tray::TrayIcon<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >,enum2$<tauri::error::Error> > >::unwrap
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\result.rs:1073
  15:     0x7ff60b571ef0 - shion_lib::run::closure$2
                               at D:\github-shion\shion\src-tauri\src\lib.rs:174
  16:     0x7ff60b268688 - core::ops::function::FnOnce::call_once<shion_lib::run::closure_env$2,tuple$<ref_mut$<tauri::app::App<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > > > > >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\ops\function.rs:250
  17:     0x7ff60b54bfa8 - alloc::boxed::impl$47::call_once<tuple$<ref_mut$<tauri::app::App<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > > > >,dyn$<core::ops::function::FnOnce<tuple$<ref_mut$<tauri::app::App<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > > > >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\alloc\src\boxed.rs:2015
  18:     0x7ff60b1e43e3 - tauri::app::setup<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tauri-2.0.0-beta.15\src\app.rs:1792
  19:     0x7ff60b1dd36a - tauri::app::impl$16::run::closure$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tauri-2.0.0-beta.15\src\app.rs:928
  20:     0x7ff60b526f8b - tauri_runtime_wry::handle_event_loop<enum2$<tauri::EventLoopMessage> >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-2.0.0-beta.12\src\lib.rs:3205
  21:     0x7ff60b52c3ae - tauri_runtime_wry::impl$45::run::closure$0<enum2$<tauri::EventLoopMessage>,tauri::app::impl$16::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventL
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-2.0.0-beta.12\src\lib.rs:2518
  22:     0x7ff60b7c48bc - tao::platform_impl::platform::event_loop::impl$3::run_return::closure$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$45::run::closure_env$0<enum2$<tauri::EventLoopMessage>,tauri::app::impl$16::run::closure_
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop.rs:237
  23:     0x7ff60c9970c5 - alloc::boxed::impl$48::call_mut<tuple$<enum2$<tao::event::Event<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,ref_mut$<enum2$<tao::event_loop::ControlFlow> > >,dyn$<core::ops::function::FnMut<tuple$<enum2$<tao::event::Event<enu
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\alloc\src\boxed.rs:2022
  24:     0x7ff60c8e8304 - tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop\runner.rs:250
  25:     0x7ff60c90cda4 - core::panic::unwind_safe::impl$23::call_once<tuple$<>,tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\panic\unwind_safe.rs:272
  26:     0x7ff60c8fb1d4 - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,tuple$<> >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\panicking.rs:554
  27:     0x7ff60c90c7e3 - tauri::image::_::impl$0::deserialize::impl$2::expecting
  28:     0x7ff60c8f9d0a - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > > >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\panicking.rs:518
  29:     0x7ff60c911ff9 - std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,tuple$<> >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\panic.rs:142
  30:     0x7ff60c8e70c5 - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::catch_unwind<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tuple$<>,tao::platform_impl::plat
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop\runner.rs:156
  31:     0x7ff60c8e802b - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::call_event_handler<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop\runner.rs:242
  32:     0x7ff60c8e7e0a - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::call_new_events<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop\runner.rs:396
  33:     0x7ff60c8e7495 - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::move_state_to<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop\runner.rs:310
  34:     0x7ff60b8bc777 - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::poll<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop\runner.rs:205
  35:     0x7ff60b7c44aa - tao::platform_impl::platform::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run_return<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$45::run::closure_env$0<en
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop.rs:246
  36:     0x7ff60b7c4c9b - tao::platform_impl::platform::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$45::run::closure_env$0<enum2$<ta
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\platform_impl\windows\event_loop.rs:221
  37:     0x7ff60b5f28a1 - tao::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$45::run::closure_env$0<enum2$<tauri::EventLoopMessage>,ta
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tao-0.27.0\src\event_loop.rs:211
  38:     0x7ff60b52beb9 - tauri_runtime_wry::impl$45::run<enum2$<tauri::EventLoopMessage>,tauri::app::impl$16::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage>
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-2.0.0-beta.12\src\lib.rs:2498
  39:     0x7ff60b1dd100 - tauri::app::App<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >::run<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tauri-2.0.0-beta.15\src\app.rs:926
  40:     0x7ff60b1dda3c - tauri::app::Builder<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >::run<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >
                               at D:\programming\rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\tauri-2.0.0-beta.15\src\app.rs:1715
  41:     0x7ff60b19a1d6 - shion_lib::run
                               at D:\github-shion\shion\src-tauri\src\lib.rs:159
  42:     0x7ff60b111159 - shion::main
                               at D:\github-shion\shion\src-tauri\src\main.rs:7
  43:     0x7ff60b1110fb - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\ops\function.rs:250
  44:     0x7ff60b11112e - core::hint::black_box
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\hint.rs:334
  45:     0x7ff60b11112e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\sys_common\backtrace.rs:155
  46:     0x7ff60b111061 - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\rt.rs:166
  47:     0x7ff60d145742 - std::rt::lang_start_internal::closure$2
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\rt.rs:148
  48:     0x7ff60d145742 - std::panicking::try::do_call
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:554
  49:     0x7ff60d145742 - std::panicking::try
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:518
  50:     0x7ff60d145742 - std::panic::catch_unwind
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panic.rs:142
  51:     0x7ff60d145742 - std::rt::lang_start_internal
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\rt.rs:148
  52:     0x7ff60b11103a - std::rt::lang_start<tuple$<> >
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\rt.rs:165
  53:     0x7ff60b111179 - main
  54:     0x7ff60d3a7104 - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  55:     0x7ff60d3a7104 - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  56:     0x7ffba768257d - BaseThreadInitThunk
  57:     0x7ffba80aaf28 - RtlUserThreadStart

@amrbashir
Copy link
Member

The backtrace wasn't that helpful, I guess I will need to reproduce this, could you provide steps to reproduce?

@hanaTsuk1
Copy link
Author

hanaTsuk1 commented Jun 27, 2024

  1. create a new project (pnpm create tauri-app --beta)
  2. as in the example above, use TrayIconBuilder
  3. build app in debug mode, create task scheduler (The following are the detailed steps)
  4. create a login task and run it with the highest permissions
  5. create a trigger, set a 3 second delay (if not set, the program may not run at all)
  6. create a action, Set the program path to C:\Windows\System32\cmd.exe, and the parameter to /k ${executable path}, use cmd /k to run (otherwise the console will automatically close after panic)

This happens only occasionally, and I hope you don't get annoyed by having to constantly shut down and log in.

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