gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
725 stars 93 forks source link

Update to java 19 #763

Closed Gamebuster19901 closed 1 year ago

Gamebuster19901 commented 1 year ago

No changes to the codebase are required.

Gamebuster19901 commented 1 year ago

Actually, Object.finalize() is deprecated and removed (never called) in jdk 18.

We should be cleaning up using try/catch/finally or try with resources

nightm4re94 commented 1 year ago

I wanted to give GraalVM CE a try for our builds. This might be a good opportunity to test that and migrate to Java 19 at the same time. Do you want to set up the GraalVM action in our build workflows?

Gamebuster19901 commented 1 year ago

I wanted to give GraalVM CE a try for our builds. This might be a good opportunity to test that and migrate to Java 19 at the same time. Do you want to set up the GraalVM action in our build workflows?

I've never worked with that software so I wouldn't really be comfortable making a PR for it.

nightm4re94 commented 1 year ago

That's alright, then go ahead as planned 👍 thank you!

Gamebuster19901 commented 1 year ago

This is pretty much done, just needs testing to make sure sounds play and that the resources are properly relinquished.

I'll try to test it by the end of the week, been feeling sick lately.

nightm4re94 commented 1 year ago

Swift recovery to you then and thanks already 😊

steffen-wilke commented 1 year ago

I've just tested this PR and it seems that sounds are not played anymore with these changes. Reproduced with utiLITI by adding a Sound source and playing it directly within the editor.

steffen-wilke commented 1 year ago

Other than that: we had a quick discussion today about Java 19 and what it brings for us and we'd really like to give Project: Panama a try to approach our native dependencies differently. This could give us the opportunity to replace JNI for input and sound.

nightm4re94 commented 1 year ago

I've just tested this PR and it seems that sounds are not played anymore with these changes. Reproduced with utiLITI by adding a Sound source and playing it directly within the editor.

Can confirm. Not only does playing sounds not work, it also crashed my entire PC without error messages.

Gamebuster19901 commented 1 year ago

Can confirm. Not only does playing sounds not work, it also crashed my entire PC without error messages.

Yikes, I'll take a look

Gamebuster19901 commented 1 year ago

I'm unable to reproduce this when manually playing a sound:

try {
    Game.audio().playSound(new Sound(new BufferedInputStream(new FileInputStream(new File("/home/gamebuster/Desktop/dolphinDump/Audio/example.mp3"))), "test"));
} catch (IOException | UnsupportedAudioFileException e) {
    e.printStackTrace();
}

However, I am unable to add sounds at all using the editor, the dropdown doesn't show imported sounds.

steffen-wilke commented 1 year ago

However, I am unable to add sounds at all using the editor, the dropdown doesn't show imported sounds.

I fixed this yesterday with #772

Gamebuster19901 commented 1 year ago

I'm still unable to reproduce this issue.

https://www.youtube.com/watch?v=1eYYqMb2Fw0

nightm4re94 commented 1 year ago

Really appreciate the effort, thank you! I've rebased your branch onto master for testing locally. When I play a sound, a thread is spawned for the playback, I can't hear anything, and the thread is never closed. (The sound used in the examples below is only around one second long) image image Each new playback results in around 20% increased CPU load: image

Also, I have verified that doing exactly the same thing on master works.

nightm4re94 commented 1 year ago

Sounds.zip These are two of the sounds I tried using (.ogg and .wav).

steffen-wilke commented 1 year ago

Maybe a Windows thing?

Gamebuster19901 commented 1 year ago

I'll try those out, I only used a .mp4 previously.

Gamebuster19901 commented 1 year ago

Issue fixed, ready for review.