godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.46k stars 21.07k forks source link

Crashing due to audio loop offset! #58313

Open QatariDev opened 2 years ago

QatariDev commented 2 years ago

Godot version

3.4 Stable

System information

Windows 11, GLES2/3

Issue description

In Godot 3.4

When you import an audio file (MP3) and then test play it in the editor, it works normally, but when you update the loop offset and return to test, Godot crashes and closes itself without warning, and oddly, when you reopen the project again, you will find the updated loop offset as expected, and if you do it again, it will do the same!

This was tested on my machine, and at first I thought it was only related to a specific project or my machine, but I can confirm that my friend tried to reproduce the issue on his machine as well, though my machine is Windows 11 and his is Windows 10. Godot crashed and closed on both of us!

Steps to reproduce

  1. Open Godot 3.4

  2. Create new project

  3. Import MP3 Audio File

  4. Play the file in the editor

  5. Pause the audio

  6. Change the loop_offset

  7. Reimport

  8. Play it again

  9. Godot will crash and close itself.

https://user-images.githubusercontent.com/100008167/154797185-5785c707-afa7-4881-81e6-04519137a8f4.mp4

Minimal reproduction project

No response

Torguen commented 1 year ago

This does not happen in: v3.5.1.stable.official [6fed1ffa3]

In my tests ( Win 10 ) it works fine but I don't know if it can be related to the length of the track that is used in that demo video, I think it should have a demo project attached.

Calinou commented 1 year ago

@QatariDev Can you (or anyone else) still reproduce this bug in Godot 3.5.1 or any later release?

If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.

QatariDev commented 1 year ago

Hello,

Unfortunately, the problem continues in my case; I am running Windows 11.

The only point of difference was that it happened after only 5 or 6 attempts, as opposed to the 3.4 release.

Godot - Loop Offset Bug.zip

Torguen commented 1 year ago

v3.5.2.rc2.official [1a2bf3eb4] - win10 64

The track is very long, it is very heavy to do this test. You will have to wait more than 5 minutes listening to the music for the problem to happen, if it happens at all. In my case the loop occurred 4 times and no crash occurred.

In my case another crash occurred for the following reason. I had Godot open with the track selected but it wasn't playing. I edited the track from an external editor to make it shorter. I save the track in original format mp3. Godot crash I guess due to audio track editing.

Ultimately, with the track still reduced to 20 seconds in order to play the loop more times, the crash never occurred.

QatariDev commented 1 year ago

Thanks for the clarification.

POWERUPT commented 1 year ago

Can confirm that this exists, and happened to me, and the song is only 85 seconds. I set the loop_offset to 1000 at first, thinking it was measured in samples, and thought that was due to the loop size as previous stated, but setting the number to 1 causes a crash as well. I am on v3.5.2.stable.official [170ba337a], Windows 10. It crashes when I change the value, then interact with the preview widget.

1 minute and 30 seconds is not considered very long as far as music is concerned, and I think this issue should be investigated further because of this. For the meantime, WAV files don't cause such an issue, as I had just been using them before changing to the .ogg format due to space issues. I don't want to have to resort to adding literally over 100 MB to my game because I can't loop common compressed audio formats, but I'll look into wav compression in the meantime.

I know it would take a bit to get this into the stable release, but if someone finds a solution that can be compiled from source, please let me know because I'm releasing a demo build in less than a month and I would like it to be as optimized as possible.

Thanks! Included is a project where the same issues occurs.

Soundtest.zip

POWERUPT commented 1 year ago

Just an addendum for my past post: I did manage to get it working. It seems that you cannot interact with the preview right after you change the loop offset. In order, what I did to when it worked was:

  1. Change the loop offset, not touching the preview
  2. Open scene with said song and save.
  3. Playing the song worked fine in the game.
  4. After closing the test, previewing the song worked fine.

So it's not as major as I thought where you can't change the loop offset at all, you just can't preview it right then and there. It's still something that should definitely be fixed, but seems workable if you are willing to work with the jank. I recommend using an external program to find loop points before setting them, like wavosaur, audacity, or some equivalent.

TL;DR Hope this gets fixed, but in the meantime just don't preview the music right away: click into another scene or asset, then back and then it should work fine.

Calinou commented 1 year ago

Note that this is likely fixed in 4.0 since the audio loop point system was rewritten there.