StackOverflowMATLABchat / mlapptools

MATLAB class containing methods for programmatic uifigure modification
http://undocumentedmatlab.com/blog/customizing-uifigures-part-2
MIT License
25 stars 11 forks source link

aboutJSLibs() fails when webwindow is not associated with a uifigure [R2017b, R2018a] #16

Closed Dev-iL closed 6 years ago

Dev-iL commented 6 years ago

The library doesn't work as-is in the new release, adaptations needed. Easiest example:

>> mlapptools.aboutJSLibs()
Error using matlab.internal.webwindow/executeJS (line 730)
Error executing JavaScript command:

    JavaScript error: Uncaught Error: undefinedModule at line 11 column 360 in https://localhost:31515/toolbox/matlab/matlab_login_framework/web/release/dojo/dojo.js

Error in mlapptools.aboutJSLibs (line 45)
            reactVersion = matlab.internal.webwindowmanager.instance ...
sco1 commented 6 years ago

Sounds like we need some unit tests ;)

Dev-iL commented 6 years ago

Upon further investigation, it appears that the issue above is not because of the version change, but rather because of some edge case I had the misfortune to encounter. As far as I understand, the command to list open webwindow objects,

matlab.internal.webwindowmanager.instance.findAllWebwindows()

might also return entries that do not correspond to a uifigure. Such webwindows don't have the usual set of attached JS libraries ~(most notably - dojo), so the dojo.require module is not recognized (which leads to the error above)~ (the difference important for this error is react). In my case, the returned "incorrect" webwindow was related to the login dialog where one enters their TMW account.

A possible solution is either to make sure that the webwindow is indeed associated with a uifigure, or simply always create a new uifigure, just in case.


While investigating the above I noticed something strange: if I run the following code

F = uifigure(); drawnow; close(F);

then switch focus from the MATLAB window to something else, then back to MATLAB - it crashes (tested on a fully updated Win10 machine). I'd love to hear if anybody else can reproduce this on their R2018a...

altmany commented 6 years ago

Not confirmed - Tested on R2017b Win10. No crash or any other unexpected behavior.

Dev-iL commented 6 years ago

Hi Yair,

I had some inaccuracies in my previous post, so I'll try to provide additional information.

All errors I encountered are in R2018a. It's possible that the uifigure-deletion crashes are due to some strange software/hardware combination on my machine (I tried clearing/refreshing prefdir + updating the GPU driver, but this didn't help).

Regarding the login window,

image

its webwindow URL is this:

'https://localhost:31515/toolbox/matlab/matlab_login_framework/web/LoginPanelContainer.html?snc=CSQTEJ'

and not what we're used to seeing in uifigures:

https://localhost:31515/toolbox/matlab/uitools/uifigureappjs/cefComponentContainer.html?channel=/uifigure/20a743fe-49f8-4d0b-8833-18024283877b&snc=234VQA

While my previous statement that it comes without dojo was incorrect, this alternate path does not recognize the react-js library (which, for uifigures, is defined inside gbtclient.js), and results in the error I got earlier.

I am yet to find a use for react in this tool, so maybe we should just revert the change where react version reporting was added.