这是indexloc提供的服务,不要输入任何密码
Skip to content

When used with bevy app, keystrokes cause EXC_BREAKPOINT. #100

@golmschenk

Description

@golmschenk

Problem

Hello! I'm attempting use rdev along with bevy. When I run both the bevy app and the rdev listen loop at the same time, rdev detects mouse events without an issue, but crashes when a keyboard event occurs. The resulting error being:

Exception: EXC_BREAKPOINT (code=1, subcode=0x18fb44924)

Minimal example

The minimal version of the code to obtain this error is:

use std::thread;
use rdev::{listen, Event};
use bevy::prelude::{App, DefaultPlugins};

fn callback(event: Event) {
    println!("My callback {:?}", event.event_type);
}

fn main() {
    thread::spawn(|| {
        if let Err(error) = listen(callback) {
            println!("Error: {:?}", error)
        }
    });
    App::new()
        .add_plugins(DefaultPlugins)
        .run();
}

This error does not occur if the rdev listen is not used or if the bevy app is not run (by replacing it with a loop{}).

Catching the error, the error seems to occur within

let layout = TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData);

at line 94 of keyboard.rs.

System:

macOS = Version 13.1 (22C65)
rust = 1.68.0-nightly
bevy = 0.9.1
rdev = 0.5.2

More complete output showing mouse input working correctly, but crashing on keyboard input:

My callback MouseMove { x: 722.30859375, y: 541.48046875 }
My callback MouseMove { x: 723.671875, y: 540.796875 }
My callback MouseMove { x: 724.60546875, y: 540.484375 }
My callback MouseMove { x: 725.54296875, y: 540.484375 }
My callback MouseMove { x: 726.48046875, y: 540.484375 }
My callback MouseMove { x: 727.41796875, y: 540.484375 }
My callback ButtonPress(Left)
My callback ButtonRelease(Left)
My callback ButtonPress(Left)
My callback ButtonRelease(Left)
My callback ButtonPress(Left)
My callback ButtonRelease(Left)

Process finished with exit code 133 (interrupted by signal 5: SIGTRAP)

(The error occurs immediately on first keyboard input, before anything is printed for that event.)

Additional notes

If, for the bevy app, I use MinimalPlugins instead of DefaultPlugins, the error does not occur. Adding back in the WinitPlugin (and it's required WindowPlugin) the error occurs again. I'm assuming there is some conflict between how rdev and winit listen for events.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions