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

Update virtual desktop Wine plugin (use Bean) #1073

Merged
merged 29 commits into from
Aug 18, 2019

Conversation

Zemogiter
Copy link
Contributor

@Zemogiter Zemogiter commented Jul 9, 2019

Description

Part of the effort to get rid of direct java calls in JS.
Fixes PhoenicisOrg/phoenicis#2021 that affects every script that needs a virtual desktop. I can't test until PhoenicisOrg/phoenicis#2023 and PhoenicisOrg/phoenicis#2040 are merged
I've tested it on Subnautica script and the new plugin works fine.

What works

Everything

What was not tested

Putting screen width and height inside the script that uses the virtual desktop plugin.

Test

  • Operating system (and linux kernel version): Ubuntu 19.04 5.0.0-20-generic
  • Hardware (GPU/CPU): i7-7700K and GTX 1080 ti

Ready for review

  • Script tested as a regular phoenicis user and working (if you have a problem -> create as draft and ask for help).
  • json-align and eslint run according to the documentation.
  • Codacy and travis checked.

Engines/Wine/Plugins/virtual desktop/script.js Outdated Show resolved Hide resolved
Engines/Wine/Plugins/virtual desktop/script.js Outdated Show resolved Hide resolved
@plata plata changed the title Update virtual desktop, using beans Update virtual desktop Wine plugin (use Bean) Jul 10, 2019
Using ifs
Moving calls to `screenManager` Bean to separate file.
Adding the header file with calls to `screenManager` Bean.
Removing extra empty lines.
Fixed indentation.
Engines/Wine/Plugins/virtual desktop/script.js Outdated Show resolved Hide resolved
Engines/Wine/Plugins/virtual desktop/script.js Outdated Show resolved Hide resolved
Engines/Wine/Plugins/virtual desktop/script.js Outdated Show resolved Hide resolved
Utils/Functions/System/virtual desktop/script.js Outdated Show resolved Hide resolved
Engines/Wine/Plugins/virtual desktop/script.js Outdated Show resolved Hide resolved
Added missing include to fix Codacy errors and, code cleanup, and removing const
@Zemogiter
Copy link
Contributor Author

Why do I get the "not defined" codacy errors?

@Zemogiter
Copy link
Contributor Author

Upon launching Subnautica script I get this error:

org.graalvm.polyglot.PolyglotException: org.graalvm.polyglot.PolyglotException: No bean named 'ScreenManager' available
	at org.phoenicis.scripts.engine.injectors.EngineInjector.throwException(EngineInjector.java:22)
	at org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.handleError(PolyglotScriptEngine.java:96)
	at org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.evalAndReturn(PolyglotScriptEngine.java:75)
	at org.phoenicis.scripts.engine.injectors.IncludeInjector.lambda$injectInto$0(IncludeInjector.java:34)
	at <js> :program(Unnamed:6:206-252)
	at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:367)
	at org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.evalAndReturn(PolyglotScriptEngine.java:73)
	at org.phoenicis.scripts.session.PhoenicisInteractiveScriptSession.eval(PhoenicisInteractiveScriptSession.java:35)
	at org.phoenicis.scripts.interpreter.BackgroundScriptInterpreter.lambda$createInteractiveSession$1(BackgroundScriptInterpreter.java:45)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by host exception: org.phoenicis.scripts.interpreter.ScriptException: org.graalvm.polyglot.PolyglotException: org.graalvm.polyglot.PolyglotException: No bean named 'ScreenManager' available

Copy link
Collaborator

@madoar madoar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix the codacy errors you need to add

// eslint-disable-next-line no-unused-vars

before the functions, for an example look at https://github.com/PhoenicisOrg/scripts/blob/master/Utils/Functions/Filesystem/Files/script.js

Utils/Functions/System/virtual desktop/script.js Outdated Show resolved Hide resolved
@Zemogiter
Copy link
Contributor Author

After that change the script starts but hangs after DXVK installation and this error is in the terminal log:

[ERROR] org.phoenicis.multithreading.ControlledThreadPoolExecutorService (l.64) - java.lang.IllegalAccessException: access to public member failed: sun.awt.SunToolkit.getScreenSize[Ljava.lang.Object;@6e8d1337/invokeVirtual, from public Lookup
	at org.graalvm.truffle/com.oracle.truffle.polyglot.HostMethodDesc$SingleMethod$MethodMHImpl.makeMethodHandle(HostMethodDesc.java:318)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.HostMethodDesc$SingleMethod$MHBase.invoke(HostMethodDesc.java:258)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.HostExecuteNode$1.executeImpl(HostExecuteNode.java:776)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.GuestToHostRootNode.execute(GuestToHostRootNode.java:87)
	at <js> :anonymous(Unnamed:28:1009-1060)
	at <js> go(engines.wine.quick_script.steam_script:145:7919-7953)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.ObjectProxyHandler.invoke(HostInteropReflect.java:678)
	at com.sun.proxy.$Proxy47.go(Unknown Source)
	at org.phoenicis.javafx.components.application.skin.ApplicationInformationPanelSkin.lambda$installScript$7(ApplicationInformationPanelSkin.java:237)
	at org.phoenicis.scripts.session.PhoenicisInteractiveScriptSession.eval(PhoenicisInteractiveScriptSession.java:35)
	at org.phoenicis.scripts.interpreter.BackgroundScriptInterpreter.lambda$createInteractiveSession$1(BackgroundScriptInterpreter.java:45)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by host exception: java.lang.IllegalStateException: java.lang.IllegalAccessException: access to public member failed: sun.awt.SunToolkit.getScreenSize[Ljava.lang.Object;@6e8d1337/invokeVirtual, from public Lookup

Exception in thread "pool-3-thread-11" java.lang.IllegalAccessException: access to public member failed: sun.awt.SunToolkit.getScreenSize[Ljava.lang.Object;@6e8d1337/invokeVirtual, from public Lookup
	at org.graalvm.truffle/com.oracle.truffle.polyglot.HostMethodDesc$SingleMethod$MethodMHImpl.makeMethodHandle(HostMethodDesc.java:318)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.HostMethodDesc$SingleMethod$MHBase.invoke(HostMethodDesc.java:258)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.HostExecuteNode$1.executeImpl(HostExecuteNode.java:776)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.GuestToHostRootNode.execute(GuestToHostRootNode.java:87)
	at <js> :anonymous(Unnamed:28:1009-1060)
	at <js> go(engines.wine.quick_script.steam_script:145:7919-7953)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.ObjectProxyHandler.invoke(HostInteropReflect.java:678)
	at com.sun.proxy.$Proxy47.go(Unknown Source)
	at org.phoenicis.javafx.components.application.skin.ApplicationInformationPanelSkin.lambda$installScript$7(ApplicationInformationPanelSkin.java:237)
	at org.phoenicis.scripts.session.PhoenicisInteractiveScriptSession.eval(PhoenicisInteractiveScriptSession.java:35)
	at org.phoenicis.scripts.interpreter.BackgroundScriptInterpreter.lambda$createInteractiveSession$1(BackgroundScriptInterpreter.java:45)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by host exception: java.lang.IllegalStateException: java.lang.IllegalAccessException: access to public member failed: sun.awt.SunToolkit.getScreenSize[Ljava.lang.Object;@6e8d1337/invokeVirtual, from public Lookup

@madoar
Copy link
Collaborator

madoar commented Jul 30, 2019

The error seems to be unrelated to the changes in this PR. It seems like you're not using the newly created script with the new function Wine.prototype.setVirtualDesktop.

@Zemogiter
Copy link
Contributor Author

Zemogiter commented Jul 30, 2019

But I do have the latest version of virtual desktop plugin in my local repo and I keep refreshing repos.
Sorry did not understood. I thought you meant the virtual desktop plugin. Now I know you meant the game script. Basically we need to change this in every script that uses the plugin:

wine.setVirtualDesktop();

Can we do this automatically?

@plata
Copy link
Collaborator

plata commented Jul 31, 2019

Should be possible with search and replace but actually I do not think that we have many scripts using this.

@Zemogiter
Copy link
Contributor Author

We have 13 scripts in total (based on runing grep -r "virtual_desktop" "./" in local repo):

  • Tom Clancy's Rainbow Six 3 : Raven Shield (Local)
  • Tom Clancy's Rainbow Six 3 : Raven Shield (Steam)
  • Caesar III (Local)
  • Caesar III (Steam)
  • Anno 2070 (Local)
  • Anno 2070 (Uplay)
  • Guild Wars 2 (Online)
  • Guild Wars 2 (Local)
  • Subnautica
  • PC Building Simulator
  • Wildlife Park 2 (Local)
  • Wildlife Park 2 (Steam)
  • Subnautica Below Zero

@madoar
Copy link
Collaborator

madoar commented Aug 3, 2019

@Zemogiter what editor are you using to work on the scripts? Are you using a "simple" editor like gedit, or are you using something more sophisticated like Atom or Visual Studio Code?

I would recommend you to use something more sophisticated when working with the scripts. For example I currently use Visual Studio Code to work with the scripts. VS Code comes with a search and replace function that works on a folder hierarchy.

Trying placing the eslint-disable line at the top to get rid of Codacy error.
Copy link
Collaborator

@madoar madoar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to block this until #1076 is merged

@Zemogiter
Copy link
Contributor Author

Ready for review.

Restored the definitions.
Copy link
Collaborator

@madoar madoar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only place where we accessed the screen width and height from inside the scripts?
If no when do you want to change the other occurrences?

I suggest to do all related changes at once in this case. This makes it easier for us to review this and it is also makes this easier to test

Engines/Wine/Plugins/virtual desktop/script.js Outdated Show resolved Hide resolved
@madoar
Copy link
Collaborator

madoar commented Aug 15, 2019

@plata I think Codacy is broken... I think it should show at least two issues (for the undefined usage of getScreenWidth and getScreenHeight) but it does not...

Updated includes
@Zemogiter
Copy link
Contributor Author

Is this the only place where we accessed the screen width and height from inside the scripts?
If no when do you want to change the other occurrences?

I suggest to do all related changes at once in this case. This makes it easier for us to review this and it is also makes this easier to test

I don't see anywhere else in the repo where we access screen dimensions.

@madoar
Copy link
Collaborator

madoar commented Aug 17, 2019

@Zemogiter I mean: when do you want to do the changes you suggested in #1073 (comment) and
#1073 (comment)?

@plata
Copy link
Collaborator

plata commented Aug 17, 2019

@madoar does ESLint show an issue if you run it manually?

@Zemogiter
Copy link
Contributor Author

@madoar preferably right after this PR is merged but do I have to make a separate PR for each script?

@madoar
Copy link
Collaborator

madoar commented Aug 17, 2019

@plata I've tried eslint for this PR, but I've seen the issue for the later commits of #1076

@Zemogiter No you don't need to open a new PR for each script it is ok (and I think in this case also better) to open a single PR where you update all scripts.

Copy link
Collaborator

@madoar madoar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plata if you have no change requests I think we can merge this PR.

@madoar
Copy link
Collaborator

madoar commented Aug 18, 2019

@ImperatorS79 you also need your approval before we can merge :)

@madoar madoar merged commit a385d1c into PhoenicisOrg:master Aug 18, 2019
@Zemogiter Zemogiter deleted the patch-4 branch August 18, 2019 12:54
petermetz pushed a commit to petermetz/scripts that referenced this pull request Jun 7, 2020
- adds a new script to access the "screenManager" Java Bean
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

Successfully merging this pull request may close these issues.

PC Building Simulator script crashes
4 participants