ccrma / chuck

ChucK Music Programming Language
http://chuck.stanford.edu/
GNU General Public License v2.0
803 stars 128 forks source link

hid problem - even demo examples don't work (tried on two different machines) #368

Open mhzareei opened 12 months ago

mhzareei commented 12 months ago

Hello, I'm not able to run any of the basic hid demo examples on miniAudicle. The various connected devices are detected but there's no hid event being triggered / recognised when pressing keys or clicking. I've tried this on two different macs (a 2017 and a 2021 model) both running Ventura (13.3.1), and I have noticed this after installing the latest update (though it had been a long time since I tried to work with hid - so not sure if the issue is related to this particular update). Neither the internal keyboard, or an external USB keyboard / mouse seem to generate a hid event...

BTW, the terminal example (kbhit.ck) runs totally ok on Terminal.

Also, just before updating one of the 2021 mac to 1.5.1.3, I tried running the examples on an earlier version (1.3. something) and that worked ok. But I don't seem to be able to get it to work even after deleting and re-installing 1.3.5.1.

Thanks for looking into this.

gewang commented 12 months ago

could this be related to macOS input monitoring permission? https://support.apple.com/guide/mac-help/control-access-to-input-monitoring-on-mac-mchl4cedafb6/mac

mine looks something like this:

Screenshot 2023-09-18 at 11 16 06 AM
mhzareei commented 12 months ago

I don't think so. I have both miniAudicle and Terminal enabled (though I don't have "chuck" exec versions).

I've just realised that miniAudicle crashes every time I stop the virtual machine after running the kb demo example.

So in short: I run the kb demo example in miniAudicle, and I do get the print command "keyboard 'Apple Internal Keyboard / Trackpad' ready", but no keyboard hits are detected. Then when I remove the shred and stop the virtual machine, miniAudicle crashes with the attached error message:

error.txt

I can run the same code (kb demo) using terminal and that works just fine.

gewang commented 12 months ago

thanks for the update! which kb demo are you running? this one? https://chuck.stanford.edu/doc/examples/hid/kb.ck

cc @spencersalazar (anything jump out at you?)

mhzareei commented 12 months ago

Yes that's the one (I've tried all the other ones too). And I get the same issue on two different macbook pros (I'm planning on try it on a mac mini and and older mac later today).

mhzareei commented 12 months ago

update: the hid examples work fine using external keyboard and mouse and a 2018 mac mini running Catalina (10.15.7) (same/latest miniaudicle/chuck version: 1.5.1.3).

mhzareei commented 12 months ago

another update: just upgraded to the latest macOs (Ventura 13.5.2) on the macbook pro and still getting the same issue. In the while true loop in the hid examples (regardless of the type keyboard/mouse), the Hid event is never detected:

while( true ){ // wait on HidIn as event hi => now; // it never reaches the this line: <<<"here?">>>; 50::ms => now; . . .

And always crashes after removing the shred and stopping the virtual machine (with the error message attached earlier).

mhzareei commented 12 months ago

Another update: A colleague just tried on his machine and ran into the same issue (no hid event detected from keyboard): He's running an older version (1.3.5.2) on a Mackboor Pro 2020, Catalina (10.15.7). Seems like a mystery...

gewang commented 12 months ago

Thank you @mhzareei for all the different testing! Although I cannot repo this on my machines here (running Monterey and Ventura), I have definitely seen this issue crop up before, and always on mac. we may need to revisit our time-honored HID implementation (by @spencersalazar) which has stood the test of time but could use an update to more recent APIs.

flagging this issue for further chuck team review! @spencersalazar @nshaheed @marisevzyl

gewang commented 12 months ago

I wish there was a way to reliably manifest the issue here, would make it much easier to debug. @mhzareei if you find any further information, please feel free to let us know using this thread!

mhzareei commented 11 months ago

@gewang yes I bet that makes it tricky. Is there anything specific you'd like me to try and report back? Alternatively, happy to organise a Zoom session and give you remote access to my machine to try things out, but I'm not sure if that'd be particularly helpful?

gewang commented 11 months ago

potentially related https://github.com/ccrma/miniAudicle/issues/72