Skip to content

Crash when trying to get any monitor #1893

@RealDrPuc

Description

@RealDrPuc

Describe the bug
The execution of the program stops when I try to use primary_monitor(), available_monitors() or current_monitor().

To Reproduce
Steps to reproduce the behavior:

  1. Add the following code to the Builder::default()
.setup(|app| {
    let window = app.get_window("main").unwrap();
    println!("This will print!");
    let _monitors = window.available_monitors();
    println!("This won't.");

    Ok(())
})
  1. Run with yarn tauri dev.
  2. See console and the program's window.
  3. See that "This won't." isn't printed and the window does not respond.

Expected behavior
Can get monitors and, at least, not crash the program.

Screenshots
Images on here (imgur link).

Platform and Versions:
OS: Windows, version 10.0.19041 X64
Node: 16.2.0
NPM: 7.13.0
Yarn: 1.22.10
Rustc: 1.52.1
Webview2: 90.0.818.66
@tauri-apps/cli: 1.0.0-beta.1
@tauri-apps/api: Not installed

Additional context

Important!
This is the output of Tao's monitor_list example:

[src\main.rs:9] window.available_monitors().collect::<Vec<_>>() = [
    MonitorHandle {
        inner: MonitorHandle(
            0x0000000000010001,
        ),
    },
]
[src\main.rs:10] window.primary_monitor() = Some(
    MonitorHandle {
        inner: MonitorHandle(
            0x0000000000010001,
        ),
    },
)

Also, this issue applies on 2 separate Windows machines.

Stack Trace
I don't know how to get a stack trace, but I will happy to provide one if the issue needs it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions