Kha icon indicating copy to clipboard operation
Kha copied to clipboard

loading stuck when audio format not supported

Open wighawag opened this issue 7 years ago • 8 comments

Currently if a sound file (converted automatically as part of kha) happen to be not supported (currently happen on safari ios) kha thrown an error.

see : https://github.com/Kode/Kha/blob/bbe457bab53abec65e467525e0bf153009798fb5/Backends/HTML5/kha/js/MobileWebAudioSound.hx#L37

It should instead return a failure callback so the app can deal with it.

I guess a failure to load at https://github.com/Kode/Kha/blob/bbe457bab53abec65e467525e0bf153009798fb5/Backends/HTML5/kha/js/MobileWebAudioSound.hx#L25

should also be sending error so the app can deal with loading errors

wighawag avatar Nov 15 '17 22:11 wighawag

I have a basic implementation for that in https://github.com/sh-dave/Kha/tree/asset-loading-failures

  • add an optional ?failed: Dynamic -> Void callback to every Assets.loadXXX() and Assets.loadXXXFromPath() function
    • defaults to haxe.Log.trace if no callback is given
  • add an failed: Dynamic -> Void callback for every LoaderImpl class i could compile
  • wraps the LoaderImpl for kore-based-backends in a try/catch

It still requires

  • an implementation for the remaining backends
  • most likely a change to Assets.loadEverything() to handle errors as well?

Should i put it up as PR in it's current state?

sh-dave avatar Nov 15 '17 23:11 sh-dave

I had a quick look, I like the uncompressSoundsFilter option too. for loadEverything, there could be a callback that return a list of failed asset ? or a callback called for each error (might be better since we can show each error as they happen)

wighawag avatar Nov 16 '17 08:11 wighawag

Uhm, I'd rather make sure there are no errors at all.

RobDangerous avatar Dec 22 '17 20:12 RobDangerous

Well if you use Assets.loadXXXFromPath() you need some kind of failure notification, b/c you never now if it's going to succeed or not.

sh-dave avatar Dec 25 '17 10:12 sh-dave

Sounds reasonable, pull request please.

RobDangerous avatar Mar 25 '18 15:03 RobDangerous

Aye, will clean it up a bit and prepare a PR. Will go with the callback for each failed assets i think.

sh-dave avatar Mar 25 '18 17:03 sh-dave

Yes, that's cool.

RobDangerous avatar Mar 25 '18 17:03 RobDangerous

Can be closed now with the merge?

sh-dave avatar May 03 '18 11:05 sh-dave