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] use enigo in tauri cause app crashed #6421

Open
jackeydou opened this issue Mar 11, 2023 · 11 comments
Open

[bug] use enigo in tauri cause app crashed #6421

jackeydou opened this issue Mar 11, 2023 · 11 comments
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@jackeydou
Copy link

Describe the bug

I try to use enigo to do some keyboard event mock in my tauri app, and it will crash when the macOS api TISCopyCurrentKeyboardInputSource or TISGetInputSourceProperty execute in enigo.

I start an issue in enigo before, but we found the crash will only appear in my Tauri app.

Reproduction

  1. register a shortcut
import { isRegistered, register, unregister } from '@tauri-apps/api/globalShortcut';
export async function registerShortcut(shortcut: string, callback: (shortcut?: string) => void) {
  await register(shortcut, (shortcut) => {
    callback(shortcut);
  });
}

and there is a log in shell:

register Accelerator { id: Some(AcceleratorId(29420)), mods: ALT, key: KeyS }
  1. write a tauri command, and invoke in javascript
#[tauri::command]
async fn paste_content(window: tauri::Window) {
    let mut enigo = Enigo::new();
    let trusted = accessibility::query_accessibility_permissions();
    if trusted {
        enigo.key_down(Key::Meta);
        enigo.key_click(Key::Layout('v'));
        enigo.key_up(Key::Meta);

    }
}
invoke("paste_content").then(async _ => {
        
 })

I use accessibility to help me request the macOS accessibility permission, and it returns true.
3. the application crashed

Expected behavior

The app does not crash.

Platform and versions

Environment
  › OS: Mac OS 13.0.0 X64
  › Node.js: 16.14.0
  › npm: 8.3.1
  › pnpm: 7.9.5
  › yarn: 3.1.1
  › rustup: 1.25.2
  › rustc: 1.68.0
  › cargo: 1.68.0
  › Rust toolchain: stable-aarch64-apple-darwin 

Packages
  › @tauri-apps/cli [NPM]: 1.2.3
  › @tauri-apps/api [NPM]: 1.2.0
  › tauri [RUST]: 1.2.4,
  › tauri-build [RUST]: 1.2.1,
  › tao [RUST]: 0.15.8,
  › wry [RUST]: 0.23.4,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:1420/
  › framework: React
  › bundler: Vite

App directory structure
  ├─ dist
  ├─ node_modules
  ├─ public
  ├─ .github
  ├─ src-tauri
  ├─ api
  ├─ .git
  ├─ .vscode
  ├─ assets
  └─ src

Stack trace

There is no output in my shell when it crashed, I try to debug it and set some breakpoints, I put the screenshots [here](https://github.com/enigo-rs/enigo/pull/161#issuecomment-1460236620)

Additional context

No response

@jackeydou jackeydou added status: needs triage This issue needs to triage, applied to new issues type: bug labels Mar 11, 2023
@yetone
Copy link

yetone commented Mar 12, 2023

I have encountered the same problem and it is very troubling.

@jackeydou
Copy link
Author

I have encountered the same problem and it is very troubling.

Did you find the cause of the crash and how did you fix it?

@garrrikkotua
Copy link

Have the same problem, though the app doesn't crash in my case

@garrrikkotua
Copy link

@zeenix @amrbashir could you please take a look? 🙏

@zeenix
Copy link
Contributor

zeenix commented Apr 13, 2023

@garrrikkotua why me? I don't even know what enigo is.

@garrrikkotua
Copy link

@garrrikkotua why me? I don't even know what enigo is.

Apologies, it was a suggestion from GitHub 😅

@amrbashir
Copy link
Member

I don't have access to a mac unfortunately so I can't triage this issue.

@parker-codes
Copy link

This is going to sound a bit strange, but try disabling spellcheck in the HTML.

<html spellcheck="false">
    <!-- ... -->
</html>

About a year ago this was causing WebKit to crash in our MacOS variant.

@pentamassiv
Copy link

A user tried it out and the problem persisted

@uwejan
Copy link

uwejan commented Jun 18, 2023

@pentamassiv Is there an update on this.
I notice app exists without any error code.
Disabeling spellchecker does not help.

@pentamassiv
Copy link

No, sorry I have not looked into it. I am not familiar at all with tauri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
Status: 📬Proposal
Development

No branches or pull requests

8 participants