haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Mainloop terminating unintentionally

Open ZwodahS opened this issue 3 years ago • 4 comments
trafficstars

This issue is from Heaps originally, and as requested, is moved here.

Original issues https://github.com/HeapsIO/heaps/issues/1068

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

OS : Mac heaps version: 57c1bd34779193636562621faca5a875b2113923 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.

ZwodahS avatar Apr 16 '22 07:04 ZwodahS

I think in Browser JS, MainLoop should never reall "exit" because you might have some other source of events (like in our case).

ncannasse avatar Apr 18 '22 09:04 ncannasse

Ping @RealyUniqueName : this used to work before MainLoop changes in ~4.2

ncannasse avatar Apr 18 '22 09:04 ncannasse

The change causes some threads tests to fail:

cases.TestMainLoop
  testNewAction_immediately: ERROR O
    missed async calls: 1
  testWorksInStaticInits_issue10114: ERROR O
    missed async calls: 1

Simn avatar May 15 '22 05:05 Simn

@RealyUniqueName @ncannasse I would appreciate if you could sort out this failing test because I'm not familiar with this code at all. This currently makes our CI red.

Simn avatar May 25 '22 05:05 Simn