This is a R2025a problem, brought to you by Mathworks massive Matlab GUI redesign, and how that interacts badly with certain peculiarities of macOS. Psychtoolbox 3.0.22.0 is not fully compatible with R2025a.
Luckily, the beeps on macOS under Matlab R2025a are annoying, but other than that, at least harmless. Iow. your data collection etc. should be fine if your participants covered their ears.
Or if you muted the sound on your system, or set the volume of system alarm sounds to 0%.
After multiple work days of investigation, reverse engineering the new Matlab way, trying and failing in various different ways to fix this problem, I now understand the reason for the problem and think I found a solution - a new hack - to hopefully get rid of the beeps. Actually separate and different hacks for Apple Silicon Macs and Intel Macs, complicating things further. These will be part of the next PTB release, but you can already download a new Screen.mexmaca64 mex file for Matlab on Apple Silicon from this link and try the fix:
https://github.com/kleinerm/Psychtoolbox-3/raw/refs/heads/master/Psychtoolbox/PsychBasic/Screen.mexmaca64
This has been successfuly tested on IntelMacs and Apple Silicon Macs with Matlab R2024b, R2025a and Octave, in regular GUI mode, and in -nondesktop command line mode from the Terminal. It has only been tested on a single display setup, but should hopefully also work on multi-display setups - can’t test that atm.
The bigger overall issue here is that with Matlab R2025a, Mathworks completely rewrote the implementation of Matlabs GUI and plotting system, cfe.:
https://blogs.mathworks.com/graphics-and-apps/2025/06/10/introducing-the-new-graphics-and-app-building-system-in-matlab-r2025a/
- Desktop OpenGL is no longer used for Matlabs plotting / data visualization functions, but WebGL is used (“OpenGL for the web” to run OpenGL code in web pages inside web browsers).
- The GUI is no longer implemented in Java, but in JavaScript, executed via the Chromium embedded framework - essentially the web rendering engine of the Chrome web browser. So the GUI is basically a collection of web pages, CSS und lots of JavaScript, rendered in a cut down web browser, as far as I understand the approach and my investigations.
- There is no longer one application process (a Unix process on Linux or macOS) that contains both the Matlab interpreter and all of Psychtoolbox, and the GUI, but instead there are at least two separate processes, one for the compute part of Matlab (backend) and one for the GUI and plotting (frontend), and both just communicate with each other via a restricted proprietary communication channel - most likely a local network loopback connection and maybe some shared memory region for efficiency?
This is a massive redesign of everything GUI related, which breaks/invalidates many of the rules in how things are working in the Matlab GUI and plotting department and how PTB interacted with Matlab’s GUI over the last 20 years.
Apart from the annoying beeps on keypress when a fullscreen window is open, there is also broken non-working GetChar(), CharAvail(), FlushEvents() and ListenChar(), as these are dependent on specifics of Matlabs old Java based GUI, which no longer exist in R2025a+. For most of these issues, the next Psychtoolbox release will have compatibility fixes - or workarounds when no proper fixes are possible. The same workarounds used on MS-Windows since Windows Vista, and on GNU/Octave.
What can’t be repaired at the moment or in the short-term (but possibly not reliably at all, unless Mathworks would add new functionality to Matlab for our specific use case) is ListenChar(2) mode and ListenChar(-1) mode, ie. prevention of spilling of keypresses into the Matlab command window in GUI mode. That spilling prevention was based on both Java for the GUI and a single-process design of Matlab, so a JavaScript GUI kills that, and if it wouldn’t kill it, the dual-process design with the GUI frontend being implemented in a separate process that is isolated from and inaccessible by Psychtoolbox, will kill it for sure.
So expect some fixes for the biggest identified issues with the next 3.0.22.1 release, but possibly not for all issues - this could be another longer term construction site.
For users of macOS on Intel Macs it might make sense to stick to Matlab R2024b or earlier permanently. Mathworks roadmap says that Matlab R2025b will be the last version to work on IntelMacs at all, and R2025a is a step down wrt. Psychtoolbox on these machines.