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

PC Building Simulator script crashes #2021

Closed
Zemogiter opened this issue Jun 25, 2019 · 19 comments · Fixed by PhoenicisOrg/scripts#1073
Closed

PC Building Simulator script crashes #2021

Zemogiter opened this issue Jun 25, 2019 · 19 comments · Fixed by PhoenicisOrg/scripts#1073

Comments

@Zemogiter
Copy link
Contributor

Expected behavior

After the .preInstall step the script should launch steam with the game ID argument and start the game installation

Actual behavior

Somewhere in that step I get this error:

java.lang.IllegalAccessException: access to public member failed: sun.awt.SunToolkit.getScreenSize[Ljava.lang.Object;@2dcb37ed/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:23:998-1049)
	at <js> go(engines.wine.quick_script.steam_script:145:7919-7953)
	at <js> run(Unnamed:12-27:353-1192)
	at org.graalvm.sdk/org.graalvm.polyglot.Value.executeVoid(Value.java:358)
	at org.phoenicis.scripts.Installer$$JSJavaAdapter.run(Unknown Source)
	at <js> :program(Unnamed:34:1318-1338)
	at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:367)
	at org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.eval(PolyglotScriptEngine.java:63)
	at org.phoenicis.scripts.interpreter.PhoenicisScriptInterpreter.runScript(PhoenicisScriptInterpreter.java:36)
	at org.phoenicis.scripts.interpreter.BackgroundScriptInterpreter.lambda$runScript$0(BackgroundScriptInterpreter.java:37)
	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;@2dcb37ed/invokeVirtual, from public Lookup

Steps to reproduce

Run PC Building Simulator script. I'll see if this issue affects other scripts to see any common treads.

System information

  • software version (git revision) of phoenicis and scripts repositories
    3e7dbda
    repo commit
    PhoenicisOrg/scripts@99abb12
  • used operating system
    Ubuntu 19.04 x64 5.0.0-17-generic
  • used Java version
    openjdk 11.0.3 2019-04-16
    OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu219.04.1)
    OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu219.04.1, mixed mode, sharing)
@ImperatorS79
Copy link
Contributor

So this is the java.awt.Toolkit.getDefaultToolkit().getScreenSize() function which does not work.

@madoar Since you want to get rid of java call in the scripts, maybe you can add a dedicated function for this ?

@Zemogiter
Copy link
Contributor Author

Why java calls in javascripts are undesirable now?

@ImperatorS79
Copy link
Contributor

From @qparis :

IMHO, Ideally, we should avoid calling directly java objects and use beans whenever it is possible.
This would make the scripts more agnostic of the main application

@Zemogiter
Copy link
Contributor Author

Should we then add something like var defaultToolkit = Bean("getDefaultToolkit"); to the `engines.wine.plugins.virtual_desktop'?

@ImperatorS79
Copy link
Contributor

With the java counterpart in phoenicis, I would assume yes, something like that (I do not know how those Beans work ^^).

@Zemogiter
Copy link
Contributor Author

This is what I made based on utils.functions.filesystem.files:

var defaultToolkit = Bean("getDefaultToolkit");

/**
 * sets Virtual Desktop with window resolution
 * @param {number} width width of virtual desktop (in px)
 * @param {number} height height of virtual desktop (in px)
 * @returns {Wine} Wine object
 */

function setVirtualDesktop (width, height) {
        defaultToolkit.getScreenSize();
}

Would this work?

@ImperatorS79
Copy link
Contributor

I do not see why you would call this function in setVirtualDesktop, but you also need a class in phoenicis for the bean (like fileUtilities for the function like cp, ...).

@Zemogiter
Copy link
Contributor Author

Shouldn't getDefaultToolkit be builtin into java?

@ImperatorS79
Copy link
Contributor

You can test ^^ (I am not a java expert).

@Zemogiter
Copy link
Contributor Author

Zemogiter commented Jun 25, 2019

Me neither.
UPDATE: After editing the virtual desktop plugin I get this error upon starting the script:

org.graalvm.polyglot.PolyglotException: No bean named 'getDefaultToolkit' available
	at org.phoenicis.scripts.engine.injectors.EngineInjector.throwException(EngineInjector.java:22)
	at org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.handleError(PolyglotScriptEngine.java:95)
	at org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.eval(PolyglotScriptEngine.java:65)
	at org.phoenicis.scripts.engine.implementation.PhoenicisScriptEngine.eval(PhoenicisScriptEngine.java:32)
	at org.phoenicis.scripts.engine.injectors.IncludeInjector.lambda$injectInto$0(IncludeInjector.java:32)
	at <js> :program(Unnamed:6:156-202)
	at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:367)
	at org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.eval(PolyglotScriptEngine.java:63)
	at org.phoenicis.scripts.interpreter.PhoenicisScriptInterpreter.runScript(PhoenicisScriptInterpreter.java:36)
	at org.phoenicis.scripts.interpreter.BackgroundScriptInterpreter.lambda$runScript$0(BackgroundScriptInterpreter.java:37)
	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: No bean named 'getDefaultToolkit' available

@madoar
Copy link
Collaborator

madoar commented Jun 25, 2019

Where exactly is the sun.awt.SunToolkit.getScreenSize call done? I agree such calls shouldn't made directly from the scripts.

@Zemogiter
Copy link
Contributor Author

I don't know. I wasn't able to find it in POL5 repo.

@plata
Copy link
Collaborator

plata commented Jun 26, 2019

Maybe this must be something like:

var screenSize = Java.type('java.awt.Toolkit').getDefaultToolkit().getScreenSize();

@madoar
Copy link
Collaborator

madoar commented Jun 26, 2019

@plata maybe we should change this to something similar to http://www.java2s.com/Code/Java/JavaFX/GetScreensize.htm (i.e. a JavaFX only solution). Ideally we implement a new Bean which does the call in Java and then returns the screen dimensions using an array or a map like @ImperatorS79 suggested. What do you think?

@qparis
Copy link
Member

qparis commented Jun 27, 2019

I think we should declare a bean ScreenManager maybe

@Zemogiter
Copy link
Contributor Author

Ok but where?

@plata
Copy link
Collaborator

plata commented Jun 29, 2019

@Zemogiter
Copy link
Contributor Author

Closing because PhoenicisOrg/scripts#1073 solves this issue.

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 a pull request may close this issue.

5 participants