Ok everyone, I think the attached screenshot illustrates this nicely:
BGM_delay_bug.png
Even locally, the music is downloaded with HTTP, precisely from the internal web app server that is launched to run your game. And as you can see in the screenshot
this process is not very quick (see the
red marker) - probably because it still sets off all the overhead of the HTTP protocol of forming a proper request with response and sending it wrapped properly as HTTP response.
I'm pretty sure this is delay we are all seeing, and I made this screenshot on a machine with a considerably fast CPU and a Solid State Disk, so it's most likely worse for all of you folks with older PCs or slower hard disks.
I can only see one feasible solution (given my guess at the problem is correct) consisting of this:
1. the BGM needs to be preloaded (like done with the "Preload Manager" plugin), even when running locally
2. the local nwjs framework used to run your desktop app needs to be convinced to cache the audio and not re-request it from HTTP internally - it doesn't currently do that for some reason, which is the reason why "Plugin Manager" would fix the problem in theory but doesn't in practice. Also see
this thread for more details on this..
Summed up: the local version still seems to play a client/server game with itself which seems to add 200ms upwards (I have seen 400ms and more without trying to stress the system in this "Network" debug tab) of "download" delay for longer BGM pieces in a local playtest run, and it doesn't even cache a BGM piece requested a few seconds ago so that the delay doesn't even get better for pieces that were just played a minute ago.
Oh and I'm pretty sure this is all happening by design, so it's most likely not much better in a playtest vs an actual release export...
-----------------------
Possible fix ?!
GalenMereth and me discussed this. If you are insane and want to try the experimental code in your project:
http://forums.rpgmakerweb.com/index.php?/topic/51422-webaudio-cache-experimental/?p=508507
This plugin should completely remove any music or sound delays (at least if audio was triggered by map BGM or event trigger), even when playing in a website.
(it's not in JS releases because it's likely to have bigger bugs, I just wrote it an hour ago)
If anyone is interested in a quick try, tell me if that helps (make sure to add "Preload Manager" first, as written in the instructions). However, don't keep the plugin regularly activated just yet though, it still needs some testing on my side to make sure it works.