HeapsIO / heaps

Heaps : Haxe Game Framework

Home Page:http://heaps.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sound only plays for a frame

ZwodahS opened this issue · comments

commented

minimum code https://github.com/ZwodahS/heaps-sound-bug

OS : Mac
heaps version: 57c1bd3
haxe: 4.2.4

SoundManager set isBlocking to false.
https://github.com/HeapsIO/heaps/blob/master/hxd/snd/Manager.hx#L151

Main loop cancel the event and only adds it back when there is a blocking event.
https://github.com/HaxeFoundation/haxe/blob/development/std/haxe/MainLoop.hx#L81-L89
https://github.com/HaxeFoundation/haxe/blob/development/std/haxe/MainLoop.hx#L124

This is fine when live update is set to true hxd.res.Resource.LIVE_UPDATE = true; (suspect that the live update created a blocking main event) or when you have mainEvent elsewhere.

with that, there is 2 solutions that I found that works
https://github.com/ZwodahS/heaps-sound-bug/blob/main/App.hx#L4-L5

However, I am curious as to what is the best way to handle this, and if this is considered a bug.

From the way you describe it it seems more like a Haxe MainLoop issue, I'm moving this on Haxe repo

Ah, can't transfer outside of heapsio group, so please reopen on http://github.com/haxeFoundation/haxe and post the link there, thanks.

Also please try with a build from https://build.haxe.org/, there have been a few fixes for MainLoop since 4.2.

commented

created the issues at HaxeFoundation/haxe#10682

As I was typing out the issue in haxe issues, I think the main problem may not be related to the main loop, at least from my understanding.

It makes sense for the SoundManager not blocking the termination of the MainLoop, but I think it is necessary for one of the updates in MainLoop to at least block the termination.

For example https://github.com/HeapsIO/heaps/blob/master/hxd/System.hl.hx#L462-L463

commented

Also please try with a build from https://build.haxe.org/, there have been a few fixes for MainLoop since 4.2.

I tried 4.2.5, the problem is still there. As mentioned, I don't think MainLoop has any issue. I think we just need a core update to block mainloop from exiting.