# OSX and Matlab 2019b issue

**URL:** <https://psychtoolbox.discourse.group/t/osx-and-matlab-2019b-issue/869>\
**Category:** Uncategorized\
**Created:** [September 27, 2019, 12:44pm UTC](https://psychtoolbox.discourse.group/t/osx-and-matlab-2019b-issue/869 "2019-09-27T12:44:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.scarfe](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@peter.scarfe](https://psychtoolbox.discourse.group/u/peter.scarfe)\
**Post date:** [September 27, 2019, 12:44pm UTC](https://psychtoolbox.discourse.group/t/osx-and-matlab-2019b-issue/869/1 "2019-09-27T12:44:57Z")

</div>

I realise this is going to be a very low priority issue, however I thought I might as well report it. To save others a headache.

All PTB demos I have tried abort under OSX 10.14.6, Matlab 2019b.&nbsp;

Here is the output for one demo (it is the same error with any demo I have tried)

> 

\>\> DriftDemo

PTB-INFO: This is Psychtoolbox-3 for Apple OS X, under Matlab 64-Bit (Version 3.0.16 - Build date: Aug &nbsp;5 2019).

PTB-INFO: OS support status: OSX version 10.14 is not officially supported or tested at all for this release.

PTB-INFO: Type 'PsychtoolboxVersion' for more detailed version information.

PTB-INFO: Most parts of the Psychtoolbox distribution are licensed to you under terms of the MIT License, with

PTB-INFO: some restrictions. See file 'License.txt' in the Psychtoolbox root folder for the exact licensing conditions.

INTERNAL PSYCHTOOLBOX ERROR

error: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PsychError\_InvalidWindowRecord

general description: &nbsp;An Invalid window record was referenced.

module name: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Screen

subfunction call: &nbsp; &nbsp; WindowKind

file name: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/Users/kleinerm/projects/OpenGLPsychtoolbox/Psychtoolbox-3/PsychSourceGL/Source/Common/Screen/WindowHelpers.c

function name: &nbsp; &nbsp; &nbsp; &nbsp;PsychCheckIfWindowRecordIsValid

line number: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;61

Error using Screen

See error message printed above.

Error in sca (line 22)

&nbsp; &nbsp; if Screen('WindowKind', win) == 1

Error in DriftDemo (line 138)

&nbsp; &nbsp; sca;

The same demos work fine under&nbsp;OSX 10.14.6, Matlab 2019a on the same machine (MBP Late 2016). So it seems Matlab 2019b is what is triggering things.&nbsp;

I have not had the chance to try PTB +&nbsp;Matlab 2019b on Windows or Linux, as we have largely transitioned away from PTB and Matlab, so do not have immediate access to these setups. I could probably test under Windows next week sometime if that is of any help.&nbsp;

No need for the usual snarky "upgrade" to Linux replies etc, etc, etc. These are very well rehearsed by now.&nbsp;

---

<div class="post-metadata">

**Author:** ![ianzolina](https://avatars.discourse-cdn.com/v4/letter/i/da6949/32.png) [@ianzolina](https://psychtoolbox.discourse.group/u/ianzolina)\
**Post date:** [September 27, 2019, 9:25pm UTC](https://psychtoolbox.discourse.group/t/osx-and-matlab-2019b-issue/869/2 "2019-09-27T21:25:04Z")

</div>

I have used 2019b with Linux and Windows, and I didn't see these error messages BTW.

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [September 28, 2019, 6:56pm UTC](https://psychtoolbox.discourse.group/t/osx-and-matlab-2019b-issue/869/3 "2019-09-28T18:56:51Z")

</div>

It's yet another bug in Apples trainwreck, this time related to GUI  
operations and multi-threading. One of two new impressively dumb bugs  
i found, apart from the even worse display timing bug, because not  
only all good things come in three. I think it was introduced a couple  
of trainwreck releases ago, but had more minor effects, e.g., that  
when onscreen windows get closed then often the screen gets stuck, not  
switching back to the GUI again, unless one does random mouse  
clicking. At some recent point, Apple redefined this design defect  
into a "feature" iow. they documented the new and backwards  
incompatible rules wrt. GUI and multi-threading, because why behave  
like a half-way responsible operating system vendor just because you  
make an operating system?  
  
While the bug is clearly in macOS and fully Apples fault, it needs  
specific multi-threading design patterns in the host application to  
trigger and express the bug in all its glory. That's why the same  
macOS bug shows different symptoms with different runtime  
environments.  
  
The problem got much worse with 10.14 Mojave, but so far it only  
really badly affected GNU/Octave, which basically abort's immediately  
if you try to open an onscreen window on Mojave, while working fine on  
older macOS releases. Matlab up to R2019a got away by dumb luck, where  
only closing the onscreen window got completely stuck - a problem we  
counteract by opening a figure window needlessly at each session,  
because for whatever reason that fixed the "stuck window" problem on  
Mojave, see [https://github.com/Psychtoolbox-3/Psychtoolbox-3/blob/master/Psychtoolbox/PsychJava/PsychJavaSwingCleanup.m#L27](https://github.com/Psychtoolbox-3/Psychtoolbox-3/blob/master/Psychtoolbox/PsychJava/PsychJavaSwingCleanup.m#L27)  
for our madness to counteract the iToys companies madness.  
  
With Ian's and Peter's results on R2019b it seems the luck of Matlab  
users has run out, and whatever Mathworks changed internally now  
triggers the same crash sequence on 10.14+ as previously only on  
Octave. Luckily Octave aborted with some bunch of useful error  
messages, whereas Matlab somehow just silently fails and aborts  
'Openwindow' in the middle of C-Code execution, probably due to  
differences in exception handling, and the PTB script continues  
running with damaged internal data structures, leading to that totally  
bogus error message about invalid window records in  
Screen('Windowkind').  
  
Anyway, i do have - quite horrifying and shaky - workarounds for the  
two new Mojave bugs, and Ian's testing on the GitHub issue already  
shows they seem to work with R2019b. However, these workarounds are  
part of some contract work, so it depends on the specifics of how that  
contract goes if and when these fixes get released.  
  
-mario  
  
  
On Fri, Sep 27, 2019 at 11:48 PM [iandol@...](mailto:iandol@...) [PSYCHTOOLBOX]  
\<[PSYCHTOOLBOX@yahoogroups.com](mailto:PSYCHTOOLBOX@yahoogroups.com)\> wrote:  

> \>  
> \>  
> \>  
> \> Hm, I have a github issue open on the same error message, which I thought was caused by the fact I'm using macOS Catalina public beta:  
> \>  
> \>  
> \> [https://github.com/kleinerm/Psychtoolbox-3/issues/156](https://github.com/kleinerm/Psychtoolbox-3/issues/156)  
> \>  
> \> But yes, I'm also using 2019b, and so it seems my error is not an OS problem but a MATLAB one. Not sure what could be causing this, but I can confirm the same error messages.  
> \>  
> \> Ian  
> \>  
> \>
