Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Bug report: loading a MP3 sometimes fails (possible race condition?) — Gideros Forum

Bug report: loading a MP3 sometimes fails (possible race condition?)

ianchiaianchia Member
edited June 2013 in Bugs and issues
In my current project, I load a MP3 UI sound fairly early on in my main.lua file, although before that, the init.lua and main.lua load a number of standard libraries (like strict and inspect), and a heavily modified iOS native uikit plugin.

I'm finding that around maybe 70 to 80% of the time, the Gideros IDE reports:

UI_prefs.mp3: No such file or directory.
stack traceback:
main.lua:40: in main chunk

when I attempt to run the project. If I keep persisting by hitting Command-R to run, it'll eventually run without falling over on line 40.

The sound code is very simple:
-- sound manager for UI sounds
sound_manager = {};
sound_manager.prefs_click = Sound.new("UI_prefs.mp3")
Could it be a race condition or something that's making the IDE fail to recognize or parse the mp3 file in adequate time to run? The mp3 is definitely in the filesystem correctly, and it does work that remaining 20% to 30% of the time.

I've attached the MP3 so you can possibly repro this bug.

Best,

- Ian

Comments

  • ar2rsawseenar2rsawseen Maintainer
    @ianchia, just tested simple example and it works with your mp3

    1) can you try removing mp3 from your project and re-adding it back
    If that does not work
    2) can you try simple example without any of the additions like plugins and other lua libraries.
  • @ar2rsaween I can try (1), but I'll have to try (2) in a couple of weeks. The project is due to ship this week and I don't have to time create a simple bug testbed I can send you this week to repro. I'm away next week. Apologies.

    @atilim - thank you. Don't spend too much time on it for now, as I can just keep hitting Command-R until it runs. (3 out of 10 ain't too bad ). If you can't repro for now, I'll build a testbed in a couple of weeks where you can repro and isolate the problem.

    Many thanks,

    - Ian
  • File:           UI_prefs.mp3
    File type ID:   MPG3
    Num Tracks:     1
    ----
    Data format:     2 ch,  48000 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame
                    no channel layout.
    estimated duration: 0.288000 sec
    audio bytes: 4608
    audio packets: 12
    bit rate: 128000 bits per second
    packet size upper bound: 968
    maximum packet size: 384
    audio data file offset: 543
    optimized
    audio 11520 valid frames + 576 priming + 1728 remainder = 13824
    @ianchia, since this is a very small file, I'd convert it to mono WAV.
    http://esem.name/sound ♫ sound and music at ShadyLabs (Clouds of Steel, Aftermath Alvin)
  • ianchiaianchia Member
    edited June 2013
    @gmarinov But the mp3 still gives me the best fidelity at the smallest size. (-;

    u-law WAV mono 13.6Kb
    IMA-ADPCM mono 8.1Kb
    mp3 48KHz stereo 5Kb

    It's a problem within Gideros Studio though - not the audio file. I'd much prefer the audio engine got the fix than making workarounds with audio files.

    ( @atilim - that's a good point - I've never seen a crash in the exported app due to the MP3 file not being found/not loading. It's a bug isolated to the Studio IDE running the app on a remote device.)

    Best,

    - Ian
  • @ianchia i dont know if this could help your case or not

    but try to add collectgarbage() before Sound.new()
    have fun with our games~
    http://www.nightspade.com
  • Thanks @Nascode - I'll give it a try and see if it does anything useful. Would be an interesting datapoint if it does, since there are a bunch of factory objects being instantiated before the sound manager object is created.
  • Hmmm, adding collectgarbage() immediately before the two lines of sound_manager lua improves it a bit. The IDE now fails about 40% to 50% of the time instead of 70% to 80% on repeated Command-R Runs. Looking closer at the code, most of the factory objects are instantiated *after* loading the MP3. The UIKit plugin is instantiated *before* the MP3, but it doesn't do any sound related things and no Lua tables are being created yet using the plugin (other than the plugin objects instantiated via Objective-C++ via the constructor). It's an interesting mystery.

    - Ian
Sign In or Register to comment.