PhoenicisOrg / scripts

Phoenicis scripts
GNU Lesser General Public License v3.0
64 stars 49 forks source link

Phoenicis doesn't work on Mac because sortVersions fails to parse json. #1256

Closed deftdawg closed 2 years ago

deftdawg commented 2 years ago

The script fails on Mac, on Linux it seems to work okay... so maybe something about the darwin file is formatted differently causing it to break.

I'm not sure how to debug the Javascript files (I'm running Phoenicis under mvnDebug + VSCode Studio trying to catch the error on the Java side without luck)... But the error from the stacktrace corresponds to this file + line:

https://github.com/PhoenicisOrg/scripts/blob/9feb4f9dbd9dc1b3a65a9b8156fe27968d78d86c/Engines/Wine/Engine/Versions/script.js#L26

[WARN ] org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO (l.56) - Installation ID (Custom Installer_1649394901627) contains invalid characters, will remove them.
[ERROR] org.phoenicis.multithreading.ControlledThreadPoolExecutorService (l.64) - TypeError: (intermediate value).from is not a function
    at <js> :=>(Unnamed:26:918-956)
    at <js> sortVersions(Unnamed:11-70:377-2514)
    at <js> :=>(Unnamed:118:4141-4175)
    at <js> module.getAvailableVersions(Unnamed:118:4104-4176)
    at <js> getLatestVersion(Unnamed:81:2912-2946)
    at <js> module.getLatestStableVersion(Unnamed:125:4286-4363)
    at <js> _determineWineVersion(Unnamed:157:4225-4281)
    at <js> go(Unnamed:26:888-926)
    at com.oracle.truffle.polyglot.PolyglotObjectProxyHandler.invoke(PolyglotObjectProxyHandler.java:103)
    at com.sun.proxy.$Proxy63.go(Unknown Source)
    at org.phoenicis.javafx.components.application.skin.ApplicationInformationPanelSkin.lambda$installScript$7(ApplicationInformationPanelSkin.java:274)
    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:829)
deftdawg commented 2 years ago

This is the only version numbers that look odd to me, but they're present in the Linux version of the file as well.

$ curlie "https://phoenicis.playonlinux.com/index.php/wine?os=darwin" | grep version | sort -u
...
                "version": "1.4.rc4-xliveless-no_xinput2",
                "version": "1.4.rc6-xliveless-no_xinput2",
...
deftdawg commented 2 years ago

Here's where it actually chokes...

DEBUG --- a: 4.19 b: 3.0-rc3
DEBUG --- aVersionParts: 4.19,4.19,, bVersionParts: 3.0-rc3,3.0,,-rc3
deftdawg commented 2 years ago

Confirmed that Array.from is not defined with this...

        if (!Array.from) { 
            console.log('Array.from is not defined!');
        }

now to figure out where the JavaScript runtime is declared and why this would be missing...

deftdawg commented 2 years ago

hmmm... set these to see if I could get past the error:

        const aVersionNumbers = [0,0];
        const bVersionNumbers = [0,0];

It then crashes later on at this

TypeError: versionsJson.filter(...).flatMap is not a function

Also looking through the script, these look like they could break on mac/darwin too...

https://github.com/PhoenicisOrg/scripts/blob/9feb4f9dbd9dc1b3a65a9b8156fe27968d78d86c/Engines/Wine/Engine/Versions/script.js#L125

https://github.com/PhoenicisOrg/scripts/blob/9feb4f9dbd9dc1b3a65a9b8156fe27968d78d86c/Engines/Wine/Engine/Versions/script.js#L129

https://github.com/PhoenicisOrg/scripts/blob/9feb4f9dbd9dc1b3a65a9b8156fe27968d78d86c/Engines/Wine/Engine/Versions/script.js#L133

deftdawg commented 2 years ago

@plata Do you know what is determining the presence or absence of these missing Array.from() and Array.flatMap() functions?

I've been googling around trying to make a connection, best I can guess is graal js is using a different ecmascript-version or something... I don't really know what I'm looking at, I have no experience with JavaFX or using JS within a Java app...

Sorry to bug you, but I need a hint as to how I might proceed to fix this. Thx.

deftdawg commented 2 years ago

Pasting in this Array polyfill into the bottom of scripts/Engines/Wine/Engine/Versions/script.js I can get through the troubles with Array missing from and flatMap... Then can select my installer and wine from different streams and builds.

Then bomb out at createContainer:

[ERROR] org.phoenicis.multithreading.ControlledThreadPoolExecutorService (l.64) - TypeError: [object Array] is not iterable
    at <js> createContainer(Unnamed:349-362:12812-13432)
    at <js> prefix(Unnamed:79:2538-2603)
    at <js> go(Unnamed:92:3662-3751)
    at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotObjectProxyHandler.invoke(PolyglotObjectProxyHandler.java:103)
    at com.sun.proxy.$Proxy67.go(Unknown Source)
    at phoenicis.javafx@5.0-SNAPSHOT/org.phoenicis.javafx.components.application.skin.ApplicationInformationPanelSkin.lambda$installScript$7(ApplicationInformationPanelSkin.java:274)
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.session.PhoenicisInteractiveScriptSession.eval(PhoenicisInteractiveScriptSession.java:35)
    at phoenicis.scripts@5.0-SNAPSHOT/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:829)

somewhere in here: https://github.com/PhoenicisOrg/scripts/blob/f967dee138b3e01244d1a3fe4ff0690c1543a5b7/Engines/Wine/Engine/Implementation/script.js#L349-L362

deftdawg commented 2 years ago

Replaced all of the const [var1,,var2] = somestring.split(); like this one through out the file:

        // const [distribution, , architecture] = subCategory.split("-");
        const distribution = subCategory.split("-")[0]; 
        const architecture = subCategory.split("-")[2];

Now I can download the Wine tarball and explode it, on tried Wine-6.5 x86 that fails with Bad CPU type in executable, tried x86 on 64 with cx and 19.0.0, get prompted to install gecko, say yes, get prompted to install again, say no...

Finally, can select what version of windows to emulate... pick Win XP... then another crash.

[ERROR] org.phoenicis.multithreading.ControlledThreadPoolExecutorService (l.65) - TypeError: (intermediate value).entries is not a function
    at <js> go(Unnamed:62:2029-2061)
    at <js> :=>(Unnamed:38:1153-1233)
    at <js> go(Unnamed:96:3793-3827)
    at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotObjectProxyHandler.invoke(PolyglotObjectProxyHandler.java:103)
    at com.sun.proxy.$Proxy67.go(Unknown Source)
    at phoenicis.javafx@5.0-SNAPSHOT/org.phoenicis.javafx.components.application.skin.ApplicationInformationPanelSkin.lambda$installScript$7(ApplicationInformationPanelSkin.java:274)
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.session.PhoenicisInteractiveScriptSession.eval(PhoenicisInteractiveScriptSession.java:35)
    at phoenicis.scripts@5.0-SNAPSHOT/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:829)
plata commented 2 years ago

It might make sense to rollback Graal to an older version (in https://github.com/PhoenicisOrg/phoenicis/blob/16143aed13e6f209f0ebd9567dc066e1b00c75d9/pom.xml#L58). After finding a working version, update until the breaking version is found. Then check in the Graal changelog for hints about the issue.

deftdawg commented 2 years ago

It might make sense to rollback Graal to an older version

Ah crap... YAll that hacking around... You're totally right!

Reapply your rollback to 21.0.0 commit and everything works with the default set of scripts: https://github.com/PhoenicisOrg/phoenicis/commit/46f860333da6ee10ce6cf7b3ed697e11efeadc21

Wonder what graal did to change the default behaviour... I'll look into it.

deftdawg commented 2 years ago

21.1.0 and below are okay... There is mention in the changelog for 21.2.0 that nashorn compatibility changed to EMCAScript 5...

This explains why Array lost a bunch of methods and broke, this comment explains.

https://github.com/PhoenicisOrg/phoenicis/blob/0550391377e14c1cab49376052be5e434526f361/phoenicis-scripts/src/main/java/org/phoenicis/scripts/engine/ScriptEngineType.java#L15-L17

I tried commenting out nashorn-compat and adding "js.ecmascript-version", "2017", but I get errors like this starting up...

[ERROR] org.phoenicis.multithreading.ControlledThreadPoolExecutorService (l.65) - org.phoenicis.scripts.exceptions.ScriptException: org.graalvm.polyglot.PolyglotException: java.lang.NoSuchMethodError: jdk.vm.ci.meta.ResolvedJavaType.link()V
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.engine.injectors.EngineInjector.throwException(EngineInjector.java:23)
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.handleError(PolyglotScriptEngine.java:96)
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.eval(PolyglotScriptEngine.java:66)
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.engine.implementation.PolyglotScriptEngine.eval(PolyglotScriptEngine.java:55)
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.engine.injectors.ScriptUtilitiesInjector.injectInto(ScriptUtilitiesInjector.java:13)
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.engine.PhoenicisScriptEngineFactory.lambda$createEngine$0(PhoenicisScriptEngineFactory.java:38)
    at java.base/java.util.Arrays$ArrayList.forEach(Arrays.java:4390)
    at phoenicis.scripts@5.0-SNAPSHOT/org.phoenicis.scripts.engine.PhoenicisScriptEngineFactory.createEngine(PhoenicisScriptEngineFactory.java:38)
    at phoenicis.engines@5.0-SNAPSHOT/org.phoenicis.engines.EngineSettingsManager.lambda$fetchAvailableEngineSettings$2(EngineSettingsManager.java:68)
    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: org.graalvm.polyglot.PolyglotException: java.lang.NoSuchMethodError: jdk.vm.ci.meta.ResolvedJavaType.link()V
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime.resolveType(GraalTruffleRuntime.java:444)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.common.TruffleCompilerRuntime.resolveType(TruffleCompilerRuntime.java:387)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.phases.TruffleSafepointInsertionPhase.<init>(TruffleSafepointInsertionPhase.java:77)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.phases.TruffleCompilerPhases.register(TruffleCompilerPhases.java:48)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.TruffleTierConfiguration.<init>(TruffleTierConfiguration.java:51)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.TruffleTierConfiguration.<init>(TruffleTierConfiguration.java:42)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl.create(HotSpotTruffleCompilerImpl.java:130)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.java.HotSpotTruffleRuntime.newTruffleCompiler(HotSpotTruffleRuntime.java:67)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.initializeTruffleCompiler(AbstractHotSpotTruffleRuntime.java:298)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime.access$200(AbstractHotSpotTruffleRuntime.java:87)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime$1.accept(AbstractHotSpotTruffleRuntime.java:253)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntime$1.accept(AbstractHotSpotTruffleRuntime.java:249)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.CompilationTask.call(CompilationTask.java:221)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.CompilationTask.call(CompilationTask.java:42)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    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)
    at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.BackgroundCompileQueue$TruffleCompilerThreadFactory$1.run(BackgroundCompileQueue.java:294)

For now I'll just stick to 21.1.0