zb3 / freej2me

A free cross-platform desktop J2ME emulator with 3D support from J2ME-Loader
Other
13 stars 2 forks source link

mac os arm64 build, 3D not working #7

Closed remixer-dec closed 3 weeks ago

remixer-dec commented 3 weeks ago

Hi.

NativeLoader: extracting native libraries to /var/folders/zk/_/T/freej2me-372917299269250
Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: Can't load library  /var/folders/zk/_/T/freej2me-372917299269250/libjavam3g.dylib

After the crash I manually checked the folder and it exists but it is empty and has no libraries inside.

P.S. A suggestion from Gemini:

The issue lies in how you determine the sourceLibraryDir. You're using System.getProperty("os.arch") to get the architecture, but for Apple Silicon Macs, this will return "aarch64" instead of "arm64".

Here's how to fix it (in pl.zb3.freej2me.NativeLoader):

String arch = System.getProperty("os.arch"); if (arch.equals("aarch64")) { arch = "arm64"; } else if (arch.equals("x86_64")) { arch = "amd64"; } String sourceLibraryDir = String.format("natives/%s-%s", osName, arch);

remixer-dec commented 3 weeks ago

oh, it is already fixed but no build available

zb3 commented 3 weeks ago

Hey, does the attached file freej2me-macos-arm64.zip work (note I had to compress it as a ZIP because GH doesn't accept jars)? If so, I'll replace it in the release

Note that I do not have any Apple Silicon machine, so the mac os arm64 wasn't really tested. I've read that there might be additional steps required on Silicon hardware, because some of these libraries aren't notarized (ANGLE libraries should be because they were just copied from chromium so they should be signed)

remixer-dec commented 3 weeks ago

It works! Thanks for a fresh build. But it has a weird bug, in order to refresh a frame I have to manually keep resizing the window, otherwise it stays showing 1 frame

zb3 commented 3 weeks ago

But it has a weird bug, in order to refresh a frame I have to manually keep resizing the window, otherwise it stays showing 1 frame

Is it for 3D apps only? The previous version didn't have that bug? What game are you running? Does it occur for other games too? Maybe I could reproduce it on Linux?

remixer-dec commented 3 weeks ago

It also happens with 2D games. The original version of freej2me (not sure which version, I downloaded it on june 30 2023) does not have this bug. It occurs in all games that I tested, but not 100% of the time, sometimes the rendering works just fine and then it stops and I have to resize the window, and it works until it freezes again. In this game the main menu works, after selecting "new game" it freezes. After resize it works again for a few seconds and freezes.

zb3 commented 3 weeks ago

This is concerning because I can't reproduce this anywhere.. so I need your assistance.

So the bug also occurs in this version, right? https://github.com/zb3/freej2me/releases/tag/bootleg-rc4-release

And you're also saying, that pressing keys on the keyboard doesn't help, because if it gets stuck, the next frame will be shown only after resizing?

Do you see any error in the console? Which java version are you using?

zb3 commented 3 weeks ago

What about this version? freej2me-macos-amd64.zip

Instead of calling the paint method on the lcd directly, I use repaint and hook the update method to prevent flicker. But I can't tell if it made any difference as I couldn't reproduce the issue locally.

remixer-dec commented 3 weeks ago

I tried RC4, RC3, RC1, and that version, all of them have the bug. Looks like some kind of (frame) buffer overflow. Keyboard does not affect anything, no errors in console. I tried both versions of java: jre1.8.0_411.jre 3 (java 8) and openjdk version "21-ea", no noticeable difference.

zb3 commented 3 weeks ago

You've tried the new version I sent today? Well wait.. it was the wrong file as I've rebuilt arm64 but sent amd64 (not rebuilt)

Here's the arm64 one: freej2me-macos-arm64.zip

remixer-dec commented 3 weeks ago

This one works! Frames are rendered correctly, the repaint fix helped.

zb3 commented 3 weeks ago

Thank you for your help, it'd otherwise be unaware of this and many people'd not report it!

I've commited https://github.com/zb3/freej2me/commit/b6a8323c4123c2921beedd883c011e576c9c6a82

and created a new release, the binary linked in the readme should now work :)