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

Having some HID issues #215

Closed
iandol opened this issue Oct 22, 2014 · 22 comments
Closed

Having some HID issues #215

iandol opened this issue Oct 22, 2014 · 22 comments

Comments

@iandol
Copy link

iandol commented Oct 22, 2014

This is on a mid-2012 retina MBP, running 3.0.12 (actually Mario's master) Matlab 2014b & Yosemite 10.10. Trying GratingDemo a second time causes a full matlab crash. I haven't had HID problems on this machine before... This was changed recently: #197

>> GratingDemo
PTB-INFO: Connection to Psychtoolbox kernel support driver instance #0 (Revision 0) established.
PTB-INFO: Disconnecting from kernel driver instance #0 for detected Intel GPU for safety reasons. setenv('PSYCH_ALLOW_DANGEROUS', '1') to override.
PTB-INFO: Connection to Psychtoolbox kernel support driver instance #0 (Revision 0) established.
PTB-INFO: Running on OSX 10.9+ - Enabling protection against AppNap and other evils.
PsychHID-ERROR: Could not enumerate HID devices (HIDBuildDeviceList() failed)! There can be various reasons,
PsychHID-ERROR: ranging from bugs in Apples HID software to a buggy HID device driver for some connected device,
PsychHID-ERROR: to general operating system malfunction. A reboot or device driver update for 3rd party HID devices
PsychHID-ERROR: maybe could help. Check the OSX system log for possible HID related error messages or hints. Aborting...
INTERNAL PSYCHTOOLBOX ERROR
    error:                PsychError_system
    general description:  Error reported by a system call
    specific description: HID device enumeration failed due to malfunction in the OSX 64 Bit Apple HID Utilities framework.
    module name:          PsychHID
    subfunction call:     
    file name:            Common/PsychHID/PsychHIDHelpers.c
    function name:        PsychHIDVerifyInit
    line number:          450
PTB-CRITICAL: Recursion stack underflow in module PsychHID! Brace for impact!
Error using PsychHID
See error message printed above.

Error in KbCheck (line 216)
        [keyIsDown, secs, keyCode]= PsychHID('KbCheck', [], ptb_kbcheck_enabledKeys);

Error in KbWait (line 142)
    [isDown, secs, keyCode, deltaSecs] = KbCheck(deviceNumber);

Error in GratingDemo (line 170)
    KbWait;
@kleinerm
Copy link

Not reproducible under either 64-Bit Octave or 64-Bit Matlab R2012a under OSX 10.9.5 under repeated runs of GratingDemo with or without 'clear all' and 'clear PsychHID' interspersed.

I also don't remember any problems with PsychHID under 10.10 with R2014b on the MacMini test machine, despite running many different demos and tests in all kind of permutations.

So i don't know. Also i spent a full awful week rewriting PsychHID to cope with all the breakage that Apple introduced with OSX 10.9 for all recent MacBook Air's, so i'm not at all motivated to spend any time soon on more fighting with Apples fragile HID implementation. Maybe you can downgrade the OS, downgrade PTB to 3.0.11 or just get the old PsychHID. Or even better, upgrade to Linux.

@iandol
Copy link
Author

iandol commented Oct 28, 2014

Yes, I saw the exasperated commit messages on your PsychHID rewrite ;-) Will experiment with replacing PsychHID as a first attempt. I'm currently working in China (everyone uses Windows) so can't test on my other Macs. As an aside, have you ever installed Linux on an external disk, so you can boot a Mac to Linux without having to repartition its internal disk? Or are you forced to rewrite the Mac bootloader?

@kleinerm
Copy link

I have an external USB drive for BIOS booting Linux on PC's. Since a few weeks i also have two USB sticks which can EFI-Boot whatever Apple machines you plug them into. It was a full 4 day fight, because of course Apples EFI is not EFI compliant but likes to think different. But in the end i managed. It's not a problem at all if you just want to dual-boot Linux from an external drive. That works with standard *buntu installer EFI-booted. The challenge was to create a stick that works on any Mac, not only on the machine where the stick was created. A good friend of mine just left for a year to MIT with her MacBookAir and a prepared Linux stick, so she has a survival kit of really well working equipment with her :). She's the only reason i even bothered to fix PsychHID for MacBookAir's, otherwise i would have closed the bug long ago as wontfix. My new host lab is a mostly Apple shop, and my first objective is to convert them as fast as possible into a Linux shop, as far as running data collection is concerned.

@kleinerm
Copy link

kleinerm commented Nov 5, 2014

Closing with "wontfix", as not reproducible on two other machines.

@kleinerm kleinerm closed this as completed Nov 5, 2014
@iandol
Copy link
Author

iandol commented Nov 10, 2014

I didn't ever seen this again after pulling some updates, and can't reproduce at all with the current PTB whatever I do, which is good!

@dhr
Copy link

dhr commented Jan 5, 2015

I'm unfortunately experiencing exactly the issue described above (MBP mid 2010, Yosemite, MATLAB R2014b, PTB 3.0.12 rev. 5797)... So far, no amount of updating, removing/reinstalling PTB seems to make a difference. @iandol, you mentioned you're no longer experiencing it? Do you remember anything specific about what changed? Thanks!

@dhr
Copy link

dhr commented Jan 5, 2015

Finally managed to fix this after debugging libHID_Utilities.a. If anyone else runs into this issue, in my case the problem occurred due to the call to IOHIDManagerOpen on line 135 of PsychSourceGL/Cohorts/HID_Utilities_64Bit/HID_Utilities.c returning kIOReturnExclusiveAccess. Apparently this means one of the HID devices has been "exclusively" seized by something on the system and can't be opened. On a hunch inspired here I scanned through the output of "ioreg" and noticed a kernel extension I'd installed long ago but wasn't actively using (Soundflower). I uninstalled it and rebooted and now PsychHID works again.

@iandol
Copy link
Author

iandol commented Jan 6, 2015

Thanks for that helpful debug info! I didn't need to uninstall any 3rd party kexts, PTB updates seemed to fix it for me without any intervention.

@iandol
Copy link
Author

iandol commented Jan 7, 2015

As an aside @dhr , how did you debug HID_Utilities.c?

@dhr
Copy link

dhr commented Jan 10, 2015

@iandol, to debug I cloned the Psychtoolbox repo and opened the Xcode project under "PsychSourceGL/Cohorts/HID_Utilities_64Bit", then built "libHID_Utilities64.a" from the project (this required tweaking a few settings to make it build in the right place and have the right name... Xcode 6 has strong opinions about putting build output in inaccessible places). From within MATLAB, I navigated to "PsychSourceGL/Source" and ran osxmakeit(8), which builds PsychHID and links it to libHID_Utilities64. Then from Xcode I attached to MATLAB (Debug > Attach to Process), set a breakpoint in HID_Utilities.c (HIDBuildMultiDeviceList) and ran KbCheck from within MATLAB, which is what was failing for me. This should then trigger the breakpoint and you can step through the HID_Utilities code within Xcode to figure out what's going on. That's the gist anyway, hope I'm not forgetting any steps.

@jennybosten
Copy link

I am experiencing the same issue trying to use psychtoolbox3 with an oculus rift on max os Yosemite and running Matlab R2014b. I have not tried dhr's debugging procedure above as I expect this won't work - the error arises only when the rift is plugged in. The program quits when I try to receive keyboard and mouse input. Does anyone have any insights?

@zampeta
Copy link

zampeta commented Aug 19, 2015

I also have the same issue, Mac Version 10.9.5, 64-bit, Matlab R2012a, and i am trying to plug in powermate
http://support.griffintechnology.com/support/powermate
and i updated Psychtoolbox to 3.0.12 and i still get this error: Check the OSX system log for possible HID related error messages or hints. Aborting...INTERNAL PSYCHTOOLBOX ERROR
Any ideas??
Thanx

@kleinerm
Copy link

Post the actual output of PTB, system log, etc. Just saying "me too" doesn't provide any useful info. If it would die for the same reason mentioned by dhr, then i'd assume some other device driver has claimed your device. Maybe you installed some powermate software which is interfering? I seem to remember somebody already had the Powermate working with PTB, although i don't remember on which OS. Or jennybosten installed some device driver from Occulus? PsychHID on OSX tries to get its hands on all USB-HID devices, so maybe it fails whenever any of them is already claimed by some other special driver? If you'd unplug your device, then run some PsychHID command like PsychHID('Devices'), then plug it in. Apple docs don't provide any info for possible failure modes of IOHIDDeviceManagerOpen(), why they would happen, or what to do if they happen. But if that would fail if at least one device is claimed by some other driver for exclusive access, this would be a problem for us.

@kleinerm
Copy link

@zampeta
Copy link

zampeta commented Aug 20, 2015

Power mate is working at a Mac 10.8.3 - 32 bit - on MatLab R2010a, by following the instructions of your link.

But now i tried to make plug it in the Mac Version 10.9.5, 64-bit, Matlab R2012a, and when i run d=PsychHID('Devices'); i get this error:

PsychHID-ERROR: Could not enumerate HID devices (HIDBuildDeviceList() failed)! There can be various reasons,
PsychHID-ERROR: ranging from bugs in Apples HID software to a buggy HID device driver for some connected device,
PsychHID-ERROR: to general operating system malfunction. A reboot or device driver update for 3rd party HID devices
PsychHID-ERROR: maybe could help. Check the OSX system log for possible HID related error messages or hints. Aborting...
INTERNAL PSYCHTOOLBOX ERROR
error: PsychError_system
general description: Error reported by a system call
specific description: HID device enumeration failed due to malfunction in the OSX 64 Bit Apple HID Utilities framework.
module name: PsychHID
subfunction call:
file name: Common/PsychHID/PsychHIDHelpers.c
function name: PsychHIDVerifyInit
line number: 453
PTB-INFO: Connection to Psychtoolbox kernel support driver instance #0 (Revision 0) established.
PTB-INFO: Connection to Psychtoolbox kernel support driver instance #1 (Revision 0) established.
PTB-INFO: Disconnecting from kernel driver instance #1 for detected Intel GPU for safety reasons. setenv('PSYCH_ALLOW_DANGEROUS', '1') to override.
PTB-INFO: Running on OSX 10.9+ - Enabling protection against AppNap and other evils.
PTB-CRITICAL: Recursion stack underflow in module PsychHID! Brace for impact!
Error using PsychHID
See error message printed above.

Any suggestions?
Thank you in advance

@kleinerm
Copy link

32-Bit PsychHID for 32-Bit Matlab on OSX used a different version of Apples HID utilities, which dealt a bit better with such problems. Those old HID utilities were broken by Apple during the 64-Bit transition, so i was forced to rewrite bits and pieces and upgrade to the more recent HID utilities which apparently handle this situation much less graceful.

Did you install a special driver or software for the Powermate? If so, i'd uninstall that.

@kleinerm
Copy link

Ok, i added some workarounds for Apples deficient OS to PsychHID for OSX. Can you UpdatePsychtoolbox to the latest beta release and check if stuff works better now?

@zampeta
Copy link

zampeta commented Aug 24, 2015

Thank you very very much Mario, it works!!!
Just for the record, what steps i took,

  1. Uninstall Powermate software
  2. Update psychtoolbox to PsychtoolboxVersion 3.0.12 - Flavor: beta
  3. Reinstall Powermate
    And now it is working!!!

@kleinerm
Copy link

Can you post PsychHID's output, so i can see how far it has to go wrt. Hacks to make the PowerMate working?

@jennybosten Does this also resolve your Oculus problems? What is your PsychHID output in this case?

@zampeta
Copy link

zampeta commented Aug 25, 2015

When i run d=PsychHID('Devices');
This is what i get:

PsychHID-ERROR: Could not enumerate and attach to all HID devices (HIDBuildDeviceList(0,0) failed)!
PsychHID-ERROR: One reason could be that some HID devices are already exclusively claimed by some 3rd party device drivers
PsychHID-ERROR: or applications. I will now retry to only claim control of a hopefully safe subset of devices like standard
PsychHID-ERROR: keyboards, mice, gamepads and supported USB-DAQ devices and other vendor defined devices and hope this goes better...
PsychHID-INFO: That worked. A subset of regular mouse, keyboard etc. input devices and maybe some vendor defined devices will be available at least.

@kleinerm kleinerm removed the wontfix label Aug 25, 2015
@kleinerm
Copy link

Ok, good, that's the minimally invasive hack for the problem.

@kleinerm
Copy link

Confirmed that this also fixes the PsychHID failure if an Oculus Rift is connected and the Oculus runtime installed and active. So we are all good again.

kleinerm added a commit that referenced this issue Dec 23, 2021
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

5 participants