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

unlockUIFig functionality discontinued #22

Open thewingit opened 6 years ago

thewingit commented 6 years ago

Problem Description

Testing the unlockUIFig from the provided example gives me following MATLAB exception:

Undefined function or variable 'wasImported'.

Error in mlapptools/unlockUIFig/checkCert (line 412)
            if wasImported

Error in mlapptools.unlockUIFig (line 351)
            assert(checkCert(), 'Certificate not imported; cannot proceed.');

I think the problem was introduced in 6e12b32f98a3426a0c7d3488311a54bee889893d and it occurs if one executes unlockUIFig after the certificate has been installed.

I fixed the issue by defining wasImported outside the if clause, but I can't see the figure anyways on my browser. I tried both Chrome and Firefox. Both give me the warning of invalid certificate and I have to add a security exception, but that's normal I think.

Steps to Reproduce the Problem

To reproduce the issue, simply try to run the code from the provided example.

Specifications

Dev-iL commented 6 years ago

Hi @thewingit,

This issue was already fixed on my own ("development") fork, but hasn't been merged yet.

Feel free to try that version out if you like!

thewingit commented 6 years ago

Hi @Dev-iL ,

Thanks for the quick reply. I'll try the forked one out.

EDIT: I tried the forked version out. The problem with the uninitialized variable is gone, however the browser still won't display the UI content, it shows me a blank page.

By inspecting the browser's dev tools, it seems that I have problems with some JS that is trying to connect with the local server:

Source map error: request failed with status 404
Resource URL: https://localhost:31515/toolbox/matlab/uitools/uifigureappjs/release/gbtclient/gbtclient.js
Source Map URL: gbtclient.js.map[Learn More]
Source map error: request failed with status 404
Resource URL: https://localhost:31515/toolbox/matlab/uitools/uifigureappjs/release/dojo/dojo.js
Source Map URL: dojo.js.map[Learn More]
Source map error: request failed with status 404
Resource URL: https://localhost:31515/toolbox/matlab/uitools/uifigureappjs/release/gbtclient/browsercheck.js
Source Map URL: browsercheck.js.map[Learn More]

It seems from the error log that the MessageService tries to connect 30 times and then fails completely.

Anyway, it might be related to my system.

Dev-iL commented 6 years ago

@thewingit Unfortunately I haven't seen your edit earlier since I wasn't notified about it (unlike when you post a new reply).

What you describe is the same issue that was discussed at length in the last PR. While I have provided detailed steps for, it didn't seem to help Yair.

I run into this issue from time to time myself, and the way I solve it is by running the figure code twice - the first time around we get a blank page, but the 2nd time it works. Note that it is important NOT TO CLOSE the browser window in which the non-working 1st tab was created. After the 2nd (working) tab is opened, the 1st can be closed.

If this doesn't work for you, feel free to contact me in chat, and I'll try to assist you.

thewingit commented 6 years ago

Hi @Dev-iL ,

thank you for your response. I tried what you mentioned but it doesn't seem to work, either. I tried also to comment out the certificate line in the internal webwindow source code, but this seems to break MATLAB somehow (the figure is not displayed at all and I got stuck while exiting).

BTW i get the same problem you posted in the PR's comments.

To me it seems pretty much an authentication problem, as the local server refuses to let the browser connect to the messaging service.

Dev-iL commented 6 years ago

Unfortunately this functionality is not very stable. Although I got it working on several different systems and different MATLAB releases (some were clean MATLAB installs), other users of the tool seem to have difficulties. I'm not sure what exactly I'm doing differently, but here are the steps I take:

What is your default browser? When you tried it with Firefox, did you import the certificate using the dedicated Firefox dialogs, or did you rely on the OS import? For Firefox, different steps are required (they are mentioned inside the subfunction checkCert).


1 Although this used to work in older releases, this method is completely invalid as of R2017b.

thewingit commented 6 years ago

Hi @Dev-iL ,

sorry I'm responding that late. I didn't find the time to work on this further.

I tried your steps in Google Chrome, Mozilla Firefox and Microsoft Edge browsers by setting them as default browser and by calling them from MATLAB directly using your example ( web(hWW.URL,'-browser'); ), respectively. It seems that none of them work.

Anyways I want to thank you for your support. As soon as I have time to work on this, I will let you know.

Khlick commented 6 years ago

@thewingit I empathize, I was having a frustrating time with this same issue at first.

When we 'unlock' the figure for viewing in an external browser we are essentially tell MATLAB that the host is undefined, which should bypass a browser-checking script MATLAB has written into the uifigure. For whatever reason, this check will fail sometimes if the channel being opened to browser has some 'not-ready' status.

What I have found works for me on Chrome Version 68.0.3440.106 (Official Build) (64-bit) (Windows 10 64bit) with MATLAB 2018a is if I open chrome before launching MATLAB, unlockUIFig from @Dev-iL 's branch works every time. At one point though, it suddenly stopped working and I had to manually reinstall the certificate through chrome's certificate manager. I could not ascertain exactly why this happened or why reinstalling the certificate helped.

thewingit commented 6 years ago

Hey @Khlick, thanks for the feedback! I will give it a try as soon as possible.

Dev-iL commented 1 year ago

According to this comment:

... you can turn on debugging by running:

matlab.internal.webwindow('http://example.com', 'DebugPort', 4040)

before any other App, or kill all MatlabWindow applications (from task manager) before the command. Then go with Chrome to http://localhost:4040/.

... so this might be another thing to try.