KbDemo failure under Big Sur

Here’s a new one. Seems to affect some new Macs running Big Sur.

KbDemo

PTB-WARNING: During PsychHID(‘KbCheck’): Some other running application is preventing me from accessing … (not sure what it says here)

PTB-WARNING: This is likely a security measure, e.g. to protect some active password entry field

PTB-WARNING: Please identify and quit the offending application. E.g., some versions of firefox are … (not sure what it says here, either)

PTB-WARNING: During PsychHID(‘KbCheck’): Some other running application is preventing me from accessing … (not sure what it says here)

PTB-WARNING: This is likely a security measure, e.g. to protect some active password entry field

PTB-WARNING: Please identify and quit the offending application. E.g., some versions of firefox are … (not sure what it says here, either)

PTB-WARNING: During PsychHID(‘KbCheck’): Some other running application is preventing me from accessing … (not sure what it says here)

PTB-WARNING: This is likely a security measure, e.g. to protect some active password entry field

PTB-WARNING: Please identify and quit the offending application. E.g., some versions of firefox are … (not sure what it says here, either)

PTB-WARNING: During PsychHID(‘KbCheck’): Some other running application is preventing me from accessing … (not sure what it says here)

PTB-WARNING: This is likely a security measure, e.g. to protect some active password entry field

PTB-WARNING: Please identify and quit the offending application. E.g., some versions of firefox are … (not sure what it says here, either)

in other words, it’s an infinite loop. Anyone have any ideas?

Big Sur is not yet officially supported or tested, but almost certainly worse than Catalina. Searching on the forum may help if you use the right search terms. Other than that there is priority support if you feel like buying another license.

-mario

My laptop updated to Big Sur and I needed to do a few things to get Psychtoolbox running as usual. I’m not sure which steps are necessary since I did all of them at once, so maybe try running KbDemo after each step to see whether one of the earlier ones is sufficient on its own.

Go to System Preferences > Security & Privacy and try clicking the lock in the bottom left corner. If you can’t get past the pop-up asking you to authorize changes, there is a reason. Big Sur has a bug where it seems to forget how to accept user passwords, which are needed to give MATLAB the right permissions to run Psychtoolbox. Try step 2 on this help article, which fixed things for me: Can't Enter Your Password in macOS Big Sur? Here's How to Fix It

If you do an SMC reset and Psychtoolbox still isn’t working, go back to System Preferences > Security & Privacy, click the lock, and enter your password so you can make changes. Under the Privacy tab, you’ll need to give MATLAB access to a few things for Psychtoolbox to run smoothly. I found that in Catalina, “input monitoring” was all MATLAB needed, but in Big Sur, it might also need “full disk access.” Check one or both of those items and then click the lock again and/or restart your computer to make sure the changes are accepted.

Let me know if the SMC reset, increased permissions, or both do the trick for you as they did for me.

1 Like

thanks for this. if i hear back from this student running Big Sur, I’ll let you know.

Student writes, “Yeah that all worked, had to allow MATLAB access on accessibility, input monitoring, and full disk access.”

Alas, it seems I now have another student with identical symptoms as described above, with the exception that mcwilson844’s suggestions didn’t help.
I also have a new license for you, Mario. Cheers

I deleted the license key from your previous post, you need to post the authentication token generated from the key, not the key itself, as that would allow anybody to abuse your key.

But back on topic, that’s unfortunate, because mcwilson844’s advice, which was based on some earlier advice of mine, is the only advice i could have given. So if that doesn’t work, i am out of ideas as well. Maybe the student made a mistake? Another thing that seems to have worked in the past on Catalina in at least one case, was to remove the permissions again, then wipe Matlab off the disc, then reinstall Matlab and then do the permission thing again. The “input monitoring” is what PTB’s KbCheck needs, the “disc access” might be something that Matlab needs to access the document folder and other locations, independent of PTB. The SMC reset advice has likely nothing to do with Matlab permissions, but with that new additional macOS 11 bug that it doesn’t accept admin passwords from users in the first place.

Please note again that macOS 11 Big Sur is not an officially supported or tested OS yet, so the advice that can be given is very limited. Multiple very severe bugs which can turn your machine into a brick upon installation of macOS 11, requiring expensive repair by Apple, make it too risky to install on my MBP 2017 machine, which it is known to have a tendency to kill upon installation. I’m constantly baffled by the kind of Apple screwups that Apple customers put up with to get a worse computing experience for a higher price in the end than what they’d get from other operating systems and hardware.

-mario

Hi there,

I’m experiencing a related issue. I may overlook something stupid, but here we go:

Since updating to Big Sur (yeah, I know…; Matlab_R2021a; MBAir, 2020) KbCheck threw a PsychHID Error message explaining how to update the security settings under MacOS. Doing this for “input monitoring” alone didn’t help, but throwing ‘disk access’ and ‘accessibility’ into the mix at least lead to a different error.

Now I don’t get the PsychHID Error any longer, but a Matlab error in KbCheck:

“Operands to the logical and (&&) and or (||) operators must be convertible to logical scalar values.
Error in KbCheck (line 247)
if allowPsychHID && (~IsWin || (IsWin && ~isempty(deviceNumber) && (deviceNumber >= 0) && ~ismember(deviceNumber, kbs)))”

The problem appears to be that allowPsychHID is empty.

Any ideas on how to fix this?

Many thanks,
Ben

Here’s the support token: HEXWDXTT-2021630191233:d3758905c2506add5d0c6a9d4462a2721854b7af7542b999b63530ceb1cd8310

The only way that could happen is if the top of KbCheck.m would abort with an error, e.g., a PsychHID error, before assigning allowPsychHID = 1.

Did you do a clear all after the PsychHID error, or better a restart of Matlab?

[Used 12 minutes of prio support].

Indeed - a clear all brings me back to square one and the original error message. I guess this means my best shot would be to remove permissions and try a reinstall of Matlab?

What is the error message?

[Used 13 minutes of prio support]

Sadly, removing permissions, deleting Matlab and reinstalling it didn’t help either. Here’s the error message:

PsychHID-ERROR: During PsychHID invocation: macOS is preventing access to HID input devices like keyboard, keypad and mouse!
PsychHID-ERROR: This is because permission for ‘Input Monitoring’ is denied to Matlab 64-Bit, or to Terminal.app, if you started Matlab 64-Bit from a Terminal.
PsychHID-ERROR: Please rectify this manually now:
PsychHID-ERROR:
PsychHID-ERROR: 1. Quit Matlab 64-Bit, and also Terminal if it was used to launch Matlab 64-Bit.
PsychHID-ERROR: 2. Open ‘System Preferences’, then go to the ‘Security & Privacy’ control panel.
PsychHID-ERROR: 3. Select the ‘Privacy’ tab, and then in the list on the left, the item ‘Input Monitoring’.
PsychHID-ERROR: 4. Make sure that Matlab 64-Bit, or similar, or maybe Terminal instead, is listed in the list on the right.
PsychHID-ERROR: E.g., names could be ‘Terminal’ or ‘Octave’ something, or ‘MATLAB_R2020b.app’ or similar for Matlab.
PsychHID-ERROR: 5. Make sure that the checkbox next to the name of the item is checked.
PsychHID-ERROR: 6. Restart Matlab 64-Bit.
PsychHID-ERROR: 7. Execute the ‘KbCheck’ command as a simple test, which should hopefully work now without errors.
PsychHID-ERROR: 8. If it doesn’t work, retry the procedure - rinse, wash, repeat.
PsychHID-ERROR: 9. If it works without errors, retry if your own scripts or our demos now work again.
PsychHID-ERROR: 10. If none of this works, you may be able to buy paid priority support from us: ‘help PsychPaidSupportAndServices’.

Error in function : Usage error
PsychHID-CRITICAL: PsychHID disabled due to macOS security restrictions! Emergency shutdown! ‘clear all’ or restart your application.

PTB-CRITICAL: Recursion stack underflow in module PsychHID! Brace for impact!
Error using PsychHID
Usage:

(null)

Error in KbCheck (line 182)
d = PsychHID(‘Devices’);

Sorry, i don’t have any ideas how to resolve it further. The measures listed in the PsychHID output are what solves it on Catalina, and what should solve it on later macOS versions. I’ve worked with another user off-list just a bit over a month ago trying to resolve the same issue, and we didn’t find a solution in over a dozen hours, and there wasn’t any discernable pattern of when it works and when it doesn’t on macOS 11. We also had cases where Octave worked when launched from a terminal, but not Matlab, or vice versa.

So all you can do is various permutations of what is proposed in this thread, in the hope that at some point it starts working, like reinstalling Matlab, or removing all Matlab related items from the security settings, and then going through the procedure again, maybe also quitting and restarting Matlab inbetween - or maybe restarting the machine inbetween? Maybe reinstalling the machine from scratch would help, maybe not.

I think when PsycHID throws this error it will also try to pop up the security dialog that is supposed to guide you through setup, and sometimes that works and sometimes it doesn’t, and sometimes the popup appears hidden behind other windows, because of macOS GUI bugs, so …

A lot of time was spent looking at macOS source code and public bug reports, and api docs, and other stuff like WWDC content wrt. the latest macOS security B.S. without success, so it is very unlikely that spending more time on this would unearth any new solutions wrt… macOS11, at most it would burn through your prio support contingent…

I’ll consider this support request finished at 15 minutes and 1 incident used up. Lets cut your losses here.

Sorry,
-mario

As a followup, this OpenRadar bug report:
https://openradar.appspot.com/7381305
suggested that at least Catalina was/is buggy in that area, and the bug seems to not have been resolved ever. If similar bugs are present in Big Sur, then it could be that use of “Accessibility Technologies” could somehow interfere with input monitoring and thereby PsychHID. Just in case you have something in that area, enabled. Or in case the latest Matlab R2021a would trigger something… R2020b didn’t have such problems, and R2021a is not yet tested with PTB by myself. Neither is macOS 11 for the reasons mentioned above in this thread.

-mario

Thanks Mario, this is as helpful as possible! If I get something to work, I’ll ping back…

One more thing you could try, with a predicted very low chance of success, is getting the PsychHID.mexmaci64 from PTB 3.0.17.10, as that one does not have the improved diagnostic code for detecting the new broken macOS 10.15+ security measures, which was introduced in 3.0.17.11.

Download link, to be put into Psychtoolbox/PsychBasic, or simply into your current working directory + clear all + which PsychHID to confirm this file will be used, then a KbCheck on the Matlab command line:

https://github.com/Psychtoolbox-3/Psychtoolbox-3/raw/3.0.17.10/Psychtoolbox/PsychBasic/PsychHID.mexmaci64

Iow. PsychHID would not detect the problem, but blindly carry on. The most likely outcome would be new hilarious ways of failing. But in case the iToys company screwed up the api’s for detecting and handling security lockdowns themselves (something i would only expect in the world of Apple), then you might get further. Ofc. i don’t know what i would make of that, because how can you detect and resolve trouble if the api’s for detecting and resolving trouble are broken troublemakers themselves? So i hope it is not this.

Another thing i remember is that sometimes Matlab shows up in the security list for Input Monitoring as either “Matlab” (or was it Matlab.app?) and/or “Matlab R2021a.app”. Sometimes both, ie. two items, named “Matlab” and “Matlab R2021a” or such. Despite being the same application, Apples toy operating system sometimes confuses this and treats each as a separate thing, so depending on how Matlab is launched, and maybe the phase on the moon, you may need “Matlab” or “Matlab R2021a” or both in the list. Good times. By the same logic, launching Matlab from the Terminal.app could make a difference if macOS then thinks that Matlab is the terminal an applies security settings from the Terminal.

-mario

Bingo!

So, what did the trick (for my system) was adding Terminal to Input Monitoring under System Preferences → Security & Privacy and then starting Matlab from Terminal.

This worked with the up to date PsychHID mex file (PTB 3.0.17.11). Replacing it with the old mex file made no difference. It also worked regardless of whether I started Matlab as root or not.

Re different names for the Matlab app under security settings, I only see ‘Matlab R2021a.app’, which is shown as selected (with a tickmark) for Input Monitoring, but this clearly is a lie. I may try another reinstall of Matlab at some point, aiming to completely remove any remnant files before downloading anew. But for now, the Terminal solution at least is a working fix.

Thanks again Mario!