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

FileUtil is not defined error on Yamcs Studio v1.0.4 (and v1.1.0) #62

Open
tomvanbraeckel opened this issue Oct 4, 2018 · 4 comments
Open

Comments

@tomvanbraeckel
Copy link
Contributor

tomvanbraeckel commented Oct 4, 2018

The latest releases of Yamcs Studio have an issue with "FileUtil is not defined" in Javascript, which is a utility function from "Packages.org.csstudio.opibuilder.scriptUtil".

This breaks the Javascript that we use to download and visualize image files from an HTTP server for FSL high rate data.

Attached is a screenshot of the error.
hgiknfkeiejkmebl_cropped

@fqqb
Copy link
Member

fqqb commented Oct 5, 2018

This appears to be some voodoo related to the Nashorn JavaScript engine in combination with threads started from scripts (the logic in UpdateImageJ.js starts a java thread).

A magic workaround is to make sure that FileUtil is used already once before this thread is started:

So for example on top of UpdateImageJ.js change:

ConsoleUtil.writeInfo("UpdateImageJ triggered")

into

ConsoleUtil.writeInfo("UpdateImageJ triggered")
FileUtil.workspacePathToSysPath("/");

And all should work fine again.

We can keep this open a bit longer though, because I'd like to find out what exactly is causing this. I'm guessing it's somewhere deep inside Nashorn.

Hopefully the workaround works for you too.

@tomvanbraeckel
Copy link
Contributor Author

Awesome, will try, thanks!

@tomvanbraeckel
Copy link
Contributor Author

We can confirm that it works with that additional line of code!

Questions:

  • Is it safe to apply this fix to all our Javascript code that uses FileUtil so that they all work properly with both the versions that we currently use for operations (v1.0.2 and v1.0.0.beta-31) and with the version that we are currently validating for operations (v1.0.4)?

  • Will the next releases of v1.0.x include a fix for this issue or is it still unclear how to fix it? In other words, should we expect to keep the FileUtil fix in there for the foreseeable future or can it be phased out from the next releases onwards?

@fqqb
Copy link
Member

fqqb commented Oct 8, 2018

The problem is not actually specific to FileUtil. You can reproduce the same with for example ConsoleUtil (in your script this just happens to be used already before the thread is started, so there is no problem)

To your questions:

  • It should be safe to add, although really it's only needed because this particular script manually starts a java thread. For simple scripts, I'm not aware of any problems. Now I don't know how many scripts you have that do manual threading, but my guess is that this is quite exceptional.

  • Not sure yet. One thing I'd like to explore is to eliminate the need for users to use importPackage for these utility libraries. This way it should be possible to avoid the reported bug.

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

No branches or pull requests

2 participants