yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.53k stars 1.58k forks source link

4.10.6 Windows JNI error while opening jar #11074

Closed carriontrooper closed 9 months ago

carriontrooper commented 9 months ago

Is there an existing issue for this?

Game Version

4.10.6

Describe the bug

When opening the jar, an error window titled Java Virtual Machine Launcher opens with the content saying: Error: a JNI error has occurred, please check your installation and try again

I've tried re-installing, re-downloading then re-installing, and the game still opens to that error.

Steps to Reproduce

  1. Download 4.10.6 Windows version "Unciv-Windows64.zip" from GitHub Releases
  2. Extract and install
  3. Open the jar
  4. See error

Screenshots

image

Link to save file

No response

Operating System

Windows

Additional Information

Note that the Android version opens just fine

carriontrooper commented 9 months ago

After trying to rollback, turns out that the problem also exists in 4.10.5 Windows version. Android version works.

carriontrooper commented 9 months ago

Tested some more versions back and the problem started appearing in 4.10.4-gradle82 Windows version, since 4.10.4 Windows version works.

chr56 commented 9 months ago

Same. It seems that it's caused by JRE.

And it launches successfully with JRE in Adoptium Temurin 17 JDK.

yairm210 commented 9 months ago

Hard for me to remote-debug this, first issue is to figure out if this is a jar problem or a bundling problem Context: Java target is set to JRE 11, so theoretically this should run with that. Works fine on my OpenJDK 11 locally

So test no. 1 java version

Test 2, does original jar work?

yairm210 commented 9 months ago

Maybe you have JRE 8??? And the builds so far were Java 8 compatible? Who uses Java 8? That's like a decade old?! Test 1 should reveal if that's indeed the problem But that's why we have the bundle, and the Unciv.exe - so you don't need to rely on the local JRE So third question, does the .exe file work?

yairm210 commented 9 months ago

Actually tested out a virtualbox vm for Windows, but it can't run Unciv due to opengl compatibility. What this DOES prove is that the JAVA component works fine from the .exe, so my guess is that you're not running the .exe file.

SomeTroglodyte commented 9 months ago

a decade old

Wow. Pretty exact: 2014-03-18 original release date

And "test no. 1 java version" should call for a java -version in the cmd box. Meaning, if we don't tell the shell which java executable we want, which is the system default?

SomeTroglodyte commented 9 months ago

On second though - why "JNI"? That's J-ava N-ative I-nterface, far down under the hood implemented as technological nightmare to interface with platform natives. And there is one uglier use in Unciv - the use of the Win32-API FlashWindow function for some multiplayer c - ahem, attention-getting feature. And that's not the library (as in - DLL) itself that's asked for, but a proxy supplied by Java. Maybe they finally removed that, and the try-catch doesn't catch?

If that's the case then the answer is already there: Remove lines 51-54, 59, 62-70 and 76-92 in UncivWindowListener. Back to standards, don't bypass the libraries doing the platform-independence. You don't get to control how often that taskbar flashes, but who cares.

Wild guess, and made unlikely by the tidbit that I already ran >= 4.10.5 sources on a windoze studio, and no Java <17 at all available. I guess i could retry with the release's bundled jre...

SomeTroglodyte commented 9 months ago

Testing on a 22H2 box that has no Java 8 or Java 11 traces, but a java 17 from Adoptium via normal installer and full integration to path etc.

carriontrooper commented 9 months ago

Regarding running from .exe, I can't - it doesn't open unciv at all since 4.8 or something. I even checked task manager and there's no unciv process/app running, nor does a java instance. That's why I directly open the java file, which usually worked - up until 4.10.4-gradle82, I guess.

SomeTroglodyte commented 9 months ago

Only goes to show your box is not healthy. Not meant disparaging - that's the crux we all have with that platform.

repeat

SeventhM commented 9 months ago

Regarding running from .exe, I can't - it doesn't open unciv at all since 4.8 or something

Not to be disparaging... But why wasn't there an issue about this? Am I missing something or shouldn't we have investigated this a while ago?

carriontrooper commented 9 months ago

Sorry, just had time to check this, tested this with the newest release image image

SomeTroglodyte commented 9 months ago

As suspected - Java 8. So you could try the testing jar in #11121. Or wait until the next release gets triggered.

Curious question is - why does calling the exe not prefer the bundled jre? Did you delete the jre subfolder or bychance unpack only parts?

Trick for that cd orgy: If you've got the folder open in Explorer, enter cmd into its address bar (replacing entire content).

SeventhM commented 9 months ago

I forget if it was shift + right click or alt + right click in Win10 (Win11 just has powershell on normal right click), but that should also let you open command prompt in the current folder

SomeTroglodyte commented 9 months ago

...all those you can do in a powershell as well. It just takes a few (felt) hours longer to load (the shell not Unciv).

Anyway, should have asked @carriontrooper too what a jre\bin\java.exe -version in their Unciv Windows64 folder does... Wait, are those two blanks in the path a problem here??? My tests had no blanks in path...

C:\somepath>Unciv.exe

C:\somepath>2024-02-13T07:52:29.808218300Z [main] [UncivGame] [ERROR] Uncaught throwable | com.unciv.logic.UncivShowableException: Intentional crash

C:\somepath>rem (**Platform:** Desktop**Version:** 4.10.7 (Build 966)**Rulesets:** [Civ V - Gods & Kings, Civ V - Vanilla, Smoky Skies Redux, Barbarian xp farm, Dreams of Steam]**Last Screen:** `com.unciv.ui.screens.mainmenuscreen.MainMenuScreen`--------------------------------OS: Windows 10Windows 10 Enterprise Version 22H2 (Build 19045)Java: Eclipse Adoptium Temurin-11.0.22+7Max Memory: 1024 MBSystem default encoding: windows-1252--------------------------------**Message:**```com.unciv.logic.UncivShowableException: Intentional crashat com.unciv.ui.popups.options.DebugTabKt$debugTab$1$15.invoke(DebugTab.kt:148)at com.unciv.ui.popups.options.DebugTabKt$debugTab$1$15.invoke(DebugTab.kt:147)at com.unciv.ui.components.input.ActivationActionMap.activate(ActivationActionMap.kt:56)at com.unciv.ui.components.input.ActorAttachments.activate(ActorAttachments.kt:42)at com.unciv.ui.components.input.ActivationExtensionsKt.activate(ActivationExtensions.kt:17)at com.unciv.ui.components.input.ActivationListener.tap(ActivationListener.kt:15)at com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener$1.tap(ActorGestureListener.java:52)at com.badlogic.gdx.input.GestureDetector.touchUp(GestureDetector.java:206)at com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener.handle(ActorGestureListener.java:125)at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:354)at com.unciv.ui.screens.basescreen.UncivStage.access$touchUp$s80204510(UncivStage.kt:17)at com.unciv.ui.screens.basescreen.UncivStage$touchUp$1.invoke(UncivStage.kt:87)at com.unciv.ui.screens.basescreen.UncivStage$touchUp$1.invoke(UncivStage.kt:87)at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandling$1.invoke(CrashHandlingExtensions.kt:17)at com.unciv.ui.screens.basescreen.UncivStage.touchUp(UncivStage.kt:87)at com.badlogic.gdx.InputEventQueue.drain(InputEventQueue.java:70)at com.badlogic.gdx.backends.lwjgl3.DefaultLwjgl3Input.update(DefaultLwjgl3Input.java:189)at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:378)at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:193)at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:167)at com.unciv.app.desktop.HardenGdxAudio.<init>(HardenGdxAudio.kt:46)at com.unciv.app.desktop.DesktopLauncher.main(DesktopLauncher.kt:76)```)

C:\somepath>java -version
openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7)
OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (build 17.0.10+7, mixed mode, sharing)

C:\somepath>java -jar Unciv.jar
2024-02-13T07:54:48.952730200Z [main] [UncivGame] [ERROR] Uncaught throwable | com.unciv.logic.UncivShowableException: Intentional crash

C:\somepath>rem (**Platform:** Desktop**Version:** 4.10.7 (Build 966)**Rulesets:** [Civ V - Gods & Kings, Civ V - Vanilla, Smoky Skies Redux, Barbarian xp farm, Dreams of Steam]**Last Screen:** `com.unciv.ui.screens.mainmenuscreen.MainMenuScreen`--------------------------------OS: Windows 10Windows 10 Enterprise Version 22H2 (Build 19045)Java: Eclipse Adoptium Temurin-17.0.10+7Max Memory: 8112 MBSystem default encoding: windows-1252--------------------------------**Message:**```com.unciv.logic.UncivShowableException: Intentional crashat com.unciv.ui.popups.options.DebugTabKt$debugTab$1$15.invoke(DebugTab.kt:148)at com.unciv.ui.popups.options.DebugTabKt$debugTab$1$15.invoke(DebugTab.kt:147)at com.unciv.ui.components.input.ActivationActionMap.activate(ActivationActionMap.kt:56)at com.unciv.ui.components.input.ActorAttachments.activate(ActorAttachments.kt:42)at com.unciv.ui.components.input.ActivationExtensionsKt.activate(ActivationExtensions.kt:17)at com.unciv.ui.components.input.ActivationListener.tap(ActivationListener.kt:15)at com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener$1.tap(ActorGestureListener.java:52)at com.badlogic.gdx.input.GestureDetector.touchUp(GestureDetector.java:206)at com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener.handle(ActorGestureListener.java:125)at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:354)at com.unciv.ui.screens.basescreen.UncivStage.access$touchUp$s80204510(UncivStage.kt:17)at com.unciv.ui.screens.basescreen.UncivStage$touchUp$1.invoke(UncivStage.kt:87)at com.unciv.ui.screens.basescreen.UncivStage$touchUp$1.invoke(UncivStage.kt:87)at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandling$1.invoke(CrashHandlingExtensions.kt:17)at com.unciv.ui.screens.basescreen.UncivStage.touchUp(UncivStage.kt:87)at com.badlogic.gdx.InputEventQueue.drain(InputEventQueue.java:70)at com.badlogic.gdx.backends.lwjgl3.DefaultLwjgl3Input.update(DefaultLwjgl3Input.java:189)at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:378)at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:193)at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:167)at com.unciv.app.desktop.HardenGdxAudio.<init>(HardenGdxAudio.kt:46)at com.unciv.app.desktop.DesktopLauncher.main(DesktopLauncher.kt:76)```)

C:\somepath>

This shows me launching Unciv, hitting the "Crash Unciv" button, then copying the CrashScreen and pasting it into a rem. The exe one shows it ran on the exact java we bundled, the jar one on my system java.

SomeTroglodyte commented 9 months ago

No, blanks are not the problem. C:\some other path with blanks>Unciv.exe runs our java 11, just tested. Except maybe if one of those isn't a blank but some other nonprinting character that has a different encoding in windows-1252 and utf-8. Nah, too far-fetched.

SeventhM commented 9 months ago

Curious question is - why does calling the exe not prefer the bundled jre? Did you delete the jre subfolder or bychance unpack only parts?

Curious question: did it actually not prefer the bundled jre? Failure message is different (couldn't create VM vs "compiled on newer version"). Seems like the issue there is deeper.

No, blanks are not the problem

I've run games done in Shift_JIS. Actually, because reasons, I sometimes set my text editors/file managers to Shift_JIS in android to deal with some files. Windows should be able to handle stuff like that just fine, as long as it gets the characters right. The only time you should have issues with windows paths is if you hit the character limit

SomeTroglodyte commented 9 months ago

Failure message is different

Oh, true. In that case the output of what I asked above - jre\bin\java.exe -version might help a little.

Shift_JIS

Using Shift_JIS nowadays is a crime. As is using Big5, windows-1252, EBCDIC, Baudot and a few others... 🥳

Windows should be able to handle stuff like that just fine

No, it has fallen way behind. NT 3.5 had state-of-the-art encoding support back then, but today? Leaving windows-1252 as default in there and marking the switch to fix it beta? Embarrassing - because it would have been trivial to flip that default long ago. And that encoding fallback is not only used for legacy applications as the setting suggests. Most not the OS' direct fault, like apps with the question "hey that input is 8-bit and unmarked, so what encoding should I try" asking the OS. Still, I believe there were demos without third-party involvement. Then again, in this case it's not even the question of Windows handling it, but of the Java bootstrapper maybe not finding its modules archive - too far-fetched as I said.

SeventhM commented 9 months ago

link

Is on the medium. No thanks, don't feel like dropping accounts on sites and guessing whether I need to pay or not. Besides, I know all too well how annoying it is to find out it's in Shift_JIS. My favorite is having bad file names in Shift_JIS only to realize it was proper Unicode, but now I gotta switch over half my equipment

No, it has fallen way behind

Could be wrong but I believe it's more complicated than that. Modern Windows (Win11 definitely, probably Win10 and Win8) uses UTF-16, older parts of windows may or may not use windows-1252 as it was previously the standard (ah yes... Good ole excessive backwards compatibility). But most of the time it isn't needed over Utf

SomeTroglodyte commented 9 months ago

Modern Windows uses UTF-16

Yes, and the very first NT was already modern in that regard. The entire system was already unicode, only the CreateFileA, FindFileExA, etc etc non-unicode proxy API (as opposed to CreateFileW etc) was layered on top. Thirty years ago. They lost the lead to bad backwards compatibility decisions - marketing people essentially.

link is on the medium

I tend to forget such evil if it does not affect me... (Edit: Of course the article is incomplete that way, but the beginning is already good. "plain-text is a lie" is gold.)

![image](https://github.com/yairm210/Unciv/assets/63000004/e9a24f45-2888-487f-b169-388b06c42c0b) So if I can read that without giving them a iota, why not. As you can see, I got medium.com globally blocked, only to get the images, I greylisted one subdomain, and for this particular blog as source only.
carriontrooper commented 9 months ago

Well, just went and downloaded the latest java and jdk (java 8 401 and jdk 21), and now latest Unciv (4.10.8-jdktest/build 967) on windows works... when you click the jar. Exe still doesn't work. image

yairm210 commented 9 months ago

The latest version we reduced the minimum java version back to 8, would have worked even if you didn't change anything But the fact that the exe isn't working bothers me Do you have a 32 bit machine maybe...?

SomeTroglodyte commented 9 months ago

I do servers too much - I forgot 32-bit even exists anymore.

But I'd also like the question answered what a jre\bin\java.exe -version in their Unciv Windows64 folder does, might have drowned in off-tangent discussion. If output is the same, our java is incompatible with their machine - 32b sounds like a possibility. If it's different, we learn something.

~True - none of the messages here...~ No wait the second screenie in this comment does: java --version -> "64-bit server VM"

SomeTroglodyte commented 9 months ago

Leaves bad extraction or manipulation after extraction - by a bad virus scanner perhaps? Can we maybe get the folder re-zipped from their exact "problem" state and uploaded to a foss-friendly file hoster?