Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unlockUIFig functionality discontinued #22

Open
thewingit opened this issue Aug 28, 2018 · 9 comments
Open

unlockUIFig functionality discontinued #22

thewingit opened this issue Aug 28, 2018 · 9 comments

Comments

@thewingit
Copy link

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

  • MATLAB Release: R2017b
  • Operating System: Windows 10 Enterprise
  • mlapptools version (or commit link/hash): 2dcedfd
@Dev-iL
Copy link
Member

Dev-iL commented Aug 28, 2018

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
Copy link
Author

thewingit commented Aug 28, 2018

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
Copy link
Member

Dev-iL commented Aug 28, 2018

@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
Copy link
Author

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
Copy link
Member

Dev-iL commented Aug 28, 2018

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:

  • Use Firefox (in my case 62.0b20 (64-bit) ).
  • Run the part of the code that does the unlocking and the opening of the browser (example, or yours) without debugging, i.e. in one go.
  • Do not to attempt to unlock the figure, then manually get the webwindow URL and put it in a browser of your choice1 - it is important that MATLAB invokes the default system browser itself (i.e. using web(hWW.URL,'-browser')). Moreover, since MATLAB invokes the default browser, one must change the default if they want to use another browser for this.
  • If the tab shows a blank page with connection errors in the console, run the figure creation code once more. As I mentioned, it is important NOT TO CLOSE the browser window in which the non-working 1st tab was created. Only after the 2nd tab is opened (which should be working), can the 1st tab be closed.

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
Copy link
Author

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
Copy link
Contributor

Khlick commented Aug 31, 2018

@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
Copy link
Author

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

@Dev-iL Dev-iL mentioned this issue Mar 25, 2019
6 tasks
@Dev-iL
Copy link
Member

Dev-iL commented Mar 31, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants