Android, fatal crash caused by Assets.getSound , Assets.getMusic

I’ve just updated from openfl 3.4, lime 2.7.0 , too openfl 3.5.2, lime 2.8.1

when attempting to load music or sound using Assets.getMusic, and Assets.getSound , the android build is failing to respond and crashing.

e.g. my line of code causing the fatal error:
var mymusic1 = Assets.getMusic("musicassets/music1" + ext); //ext=".ogg"

fatal error details from logcat
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x316d in tid 11616 (SDLThread)

This is only affecting the Android build at the latest version (as far as i can tell, i dont build to ios yet), the same code and .ogg work correctly in html5, neko and windows targets, and also work for android target at the earlier versions (openfl 3.4, lime 2.7.0)

1 Like

Are you using legacy, or no? Thanks!

I’m not using legacy !

Okay, I think this is fixed now. I had a crash on “PlayingSound” on Android (with a current NDK release) but just fixed it in Lime, must have been a difference between older/newer NDKs (we just updated to a newer NDK to fix Android 6.0 issues)

Should be fixed with Lime 2.8.2 and OpenFL 3.5.3, just released :slight_smile:

Hi, I have the same problem with Haxe 3.2.1, Lime 2.8.2 and OpenFL 3.5.3.

Loading & playing a .wav file works, the same music in .ogg format (converted with audacity) crash the app =/

This happens with Assets.getMusic & Assets.getSound

Does the “PlayingSound” sample work, or “PiratePig”?

Hi, I’d like to retitle this thread if i may as i’ve realised the problem is different to the originally explained! I’ve just updated to the latest builds, openfl 3.5.3, lime 2.8.2 and re-tested and after considerable experimenting I’m still seeing the same Fatal signal 11 (SIGSERV) fault. I’d located where it was occuring before by adding alot of traces to my code - whilst it still appeared to be caused by Assets.getMusic / GetSound, If i completely disable the sound system and do neither, the Fatal error is still occuring, It seems to occur a certain time after the app started, regardless of code ! (it just happened to occur as sound assets are loaded, as that no doubt take considerable time complete). if 2smacks could confirm the same? - I’ll hopefully have some more time tommorow to be able to build very simple example code and see whats really occuring !

Yeah, if you can find a small sample that replicates the issue, that would be very helpful :smile:

Do you use any extensions?

Yep, it's not the "sound" system, the problem is the "sound asset loading" system, with .ogg, with android target.

I juste have this in my code :
 
        trace("start ! ");
        // var s:Sound = Assets.getMusic("snd/title_screen.mp3");   
        var s:Sound = Assets.getMusic("snd/title_screen.ogg");   
        s.play();

The mp3 with target flash works, the ogg with target windows works, but not with android, the log say : 

[...]
I/trace   (23611): Main.hx:21: start ! 
E/SPPClientService(23715): ShipBuild Binary : True // dont know if it's openfl related
F/libc    (23611): Fatal signal 11 (SIGSEGV) at 0x0000000d (code=1), thread 23682 (SDLThread) // I think it's here
[...]

singmajesty : Other bug, when I try compile PiratePig or PlayingSound like you said, with flash target it works, but with android target it bug before launching the app : 

-compile:
    [javac] Compiling 5 source files to C:\HaxeToolkit\haxe\lib\openfl-samples\2,1,0\PlayingSound\Export\android\bin\bin\classes
    [javac] Note: C:\HaxeToolkit\haxe\lib\openfl-samples\2,1,0\PlayingSound\Export\android\bin\src\org\libsdl\app\SDLActivity.java uses or overrides a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.

-post-compile:

-obfuscate:

-dex:
      [dex] input: C:\HaxeToolkit\haxe\lib\openfl-samples\2,1,0\PlayingSound\Export\android\bin\bin\classes
      [dex] input: C:\HaxeToolkit\haxe\lib\openfl-samples\2,1,0\PlayingSound\Export\android\bin\deps\extension-api\bin\classes.jar
      [dex] Pre-Dexing C:\HaxeToolkit\haxe\lib\openfl-samples\2,1,0\PlayingSound\Export\android\bin\deps\extension-api\bin\classes.jar -> classes-1b6f949c6194e75735d8cac93896c6a8.jar
       [dx] unknown output extension: C:\HaxeToolkit\haxe\lib\openfl-samples\2
       [dx] usage:
       [dx]   dx --dex [--debug] [--verbose] [--positions=<style>] [--no-locals]
       [dx]   [--no-optimize] [--statistics] [--[no-]optimize-list=<file>] [--no-strict]
       [dx]   [--keep-classes] [--output=<file>] [--dump-to=<file>] [--dump-width=<n>]
       [dx]   [--dump-method=<name>[*]] [--verbose-dump] [--no-files] [--core-library]
       [dx]   [--num-threads=<n>] [--incremental] [--force-jumbo] [--no-warning]
       [dx]   [--multi-dex [--main-dex-list=<file> [--minimal-main-dex]]
       [dx]   [--input-list=<file>]
       [dx]   [<file>.class | <file>.{zip,jar,apk} | <directory>] ...
       [dx]     Convert a set of classfiles into a dex file, optionally embedded in a
       [dx]     jar/zip. Output name must end with one of: .dex .jar .zip .apk or be a directory.
       [dx]     Positions options: none, important, lines.
       [dx]     --multi-dex: allows to generate several dex files if needed. This option is 
       [dx]     exclusive with --incremental, causes --num-threads to be ignored and only
       [dx]     supports folder or archive output.
       [dx]     --main-dex-list=<file>: <file> is a list of class file names, classes defined by
       [dx]     those class files are put in classes.dex.
       [dx]     --minimal-main-dex: only classes selected by --main-dex-list are to be put in
       [dx]     the main dex.
       [dx]     --input-list: <file> is a list of inputs.
       [dx]     Each line in <file> must end with one of: .class .jar .zip .apk or be a directory.
       [dx]   dx --annotool --annotation=<class> [--element=<element types>]
       [dx]   [--print=<print types>]
       [dx]   dx --dump [--debug] [--strict] [--bytes] [--optimize]
       [dx]   [--basic-blocks | --rop-blocks | --ssa-blocks | --dot] [--ssa-step=<step>]
       [dx]   [--width=<n>] [<file>.class | <file>.txt] ...
       [dx]     Dump classfiles, or transformations thereof, in a human-oriented format.
       [dx]   dx --find-usages <file.dex> <declaring type> <member>
       [dx]     Find references and declarations to a field or method.
       [dx]     declaring type: a class name in internal form, like Ljava/lang/Object;
       [dx]     member: a field or method name, like hashCode
       [dx]   dx -J<option> ... <arguments, in one of the above forms>
       [dx]     Pass VM-specific options to the virtual machine that runs dx.
       [dx]   dx --version
       [dx]     Print the version of this tool (1.11).
       [dx]   dx --help
       [dx]     Print this message.

BUILD FAILED
C:\Users\2smacks\AppData\Local\Android\sdk\tools\ant\build.xml:888: The following error occurred while executing this line:
C:\Users\2smacks\AppData\Local\Android\sdk\tools\ant\build.xml:890: The following error occurred while executing this line:
C:\Users\2smacks\AppData\Local\Android\sdk\tools\ant\build.xml:902: The following error occurred while executing this line:
C:\Users\2smacks\AppData\Local\Android\sdk\tools\ant\build.xml:283: null returned: 1

Total time: 4 seconds
Build halted with errors.

From further testing, This appears to be .ogg file specific, but the error is a null object reference within lime/audio/AudioBuffer.hx ? so i’m really not sure what needs to be done to the .ogg to prevent a null object referece occuring. it’s still not making sense to me - here’s the very simple test code i’m using

class Main extends Sprite 
{
    public function new() 
    {
        super();
        trace("line 1");
        var mymusic1 = Assets.getMusic("musicassets/music2.ogg");        
        trace("line 2");
        var mymusic2 = Assets.getMusic("musicassets/music1.ogg");        
        trace("line 3");
    }
}

and here’s the related lines of the crash from logcat (I have 2 .ogg files, music1.ogg (270KB) is causing the error, music2.ogg (1.3MB) works correctly and plays.

I/trace ( 7289): Main.hx:17: line 1
I/trace ( 7289): Main.hx:19: line 2
E/HXCPP ( 7289): Called from ApplicationMain::main ApplicationMain.hx line 139
E/HXCPP ( 7289): Called from ApplicationMain::create ApplicationMain.hx line 26
E/HXCPP ( 7289): Called from lime.app.Preloader::create lime/app/Preloader.hx line 58
E/HXCPP ( 7289): Called from openfl.display.Preloader::start openfl/display/Preloader.hx line 93
E/HXCPP ( 7289): Called from NMEPreloader::onLoaded NMEPreloader.hx line 107
E/HXCPP ( 7289): Called from openfl.events.EventDispatcher::dispatchEvent openfl/events/EventDispatcher.hx line 95
E/HXCPP ( 7289): Called from openfl.display.DisplayObject::__dispatchEvent openfl/display/DisplayObject.hx line 270
E/HXCPP ( 7289): Called from openfl.events.EventDispatcher::__dispatchEvent openfl/events/EventDispatcher.hx line 237
E/HXCPP ( 7289): Called from openfl.display.Preloader::display_onComplete openfl/display/Preloader.hx line 129
E/HXCPP ( 7289): Called from lime.app.Preloader::start lime/app/Preloader.hx line 242
E/HXCPP ( 7289): Called from lime.app.Event_Void_Void::dispatch lime/app/Event.hx line 145
E/HXCPP ( 7289): Called from ApplicationMain::init ApplicationMain.hx line 83
E/HXCPP ( 7289): Called from ApplicationMain::start ApplicationMain.hx line 169
E/HXCPP ( 7289): Called from Type::createInstance D:\dev\HaxeToolkit\haxe\std/cpp/_std/Type.hx line 82
E/HXCPP ( 7289): Called from DocumentClass::new ApplicationMain.hx line 235
E/HXCPP ( 7289): Called from Main::new Main.hx line 20
E/HXCPP ( 7289): Called from openfl.Assets::getMusic openfl/Assets.hx line 260
E/HXCPP ( 7289): Called from lime.Assets::getAudioBuffer lime/Assets.hx line 110
E/HXCPP ( 7289): Called from DefaultAssetLibrary::getAudioBuffer DefaultAssetLibrary.hx line 212
E/HXCPP ( 7289): Called from lime.audio.AudioBuffer::fromFile lime/audio/AudioBuffer.hx line 130
E/Exception( 7289): Null Object Reference
V/SDL ( 7289): onWindowFocusChanged(): false
V/SDL ( 7289): onPause()
V/SDL ( 7289): nativePause()
E/libEGL ( 7289): call to OpenGL ES API with no current context (logged once per thread)
I/Keyboard.Facilitator( 795): onFinishInput()
V/SDL ( 7289): surfaceDestroyed()
D/ ( 7289): Surface destroy: ANDROID_NATIVE_WINDOW_MAGIC
D/ ( 7289): Surface destroy: ANDROID_NATIVE_WINDOW_MAGIC
V/SDL ( 7289): onDestroy()
W/PackageManager(28132): Failure retrieving resources for com.wigsgames.soundtest: Resource ID #0x0

Is there any way you could zip up your project and send me a direct message with a link for it? I’m wondering if this would happen on my hardware as well. If so, this would be a great way to figure out what’s going on. Thank you!

Yep !

Here a sample project :

https://www.wetransfer.com/downloads/18a0c270088699d691a1738534cf5ef920151219172816/1bde92

and my libs :
C:\Users\2smacks>haxelib list
actuate: 1.6.4 1.6.5 1.6.7 1.7.0 1.7.2 1.7.3 1.7.5 1.8.3 [1.8.6]
admob-openfl: [0.0.3]
away3d: [1.1.0]
bitmapFont: 0.9.3 [0.9.4]
BMFontHX: [1.0.1]
box2d: [1.2.3]
CameraMic: [1.0.0]
castle: [1.0.0]
flixel: 2.0.0-alpha.3 3.0.0-alpha 3.0.3 3.1.0 3.2.1 3.2.2 3.3.3 3.3.5 [3.3.6]
format: 3.0.4 3.0.5 3.1.1 [3.1.2]
ganalytics: [0.0.3]
google-play-services:
haxeui: 1.5.2 1.5.3 [1.7.13] 1.7.6
hscript: 2.0.3 [2.0.4]
HUGS: 0.1.3 0.1.4 [0.3.0]
hxcpp: 3.1.30 3.1.37 3.1.39 3.2.102 [3.2.193] 3.2.37
hxcs: 3.0.0-rc.1 3.1.1 [3.2.0]
hxlibc: 1.0.0 1.1.2 1.1.3 [1.1.4]
hxtools: 1.1.5 [1.1.6]
hyp-system: [0.2.1]
icehx-openiab: [0.1.1]
imagesaver: [0.0.3]
inthebox-macros: [1.2.0]
layout: 1.2.0 [1.2.1]
lime-samples: 2.2.0 [2.6.0]
lime-tools: 1.2.9 1.3.2 1.4.0 1.5.4 [1.5.7]
lime: 2.8.1 [2.8.2]
linden-flurry: [1.2.0]
linden-google-iap: [1.0.0]
monax: 1.4.0 1.5.0 [1.5.1]
nape-hacks: [2.0.1]
nape-symbolic: [2.0.1]
nape: 2.0.12 2.0.13 2.0.15 [2.0.16]
nme: 4.0.2 5.0.37 5.1.8 5.3.1 [5.4.2]
openfl-admob: 1.3.4 [1.4.1]
openfl-compatibility: [1.0.1]
openfl-gps-lib: 1.0.2 [1.0.4]
openfl-html5-dom: 1.2.0 1.2.1 [1.2.2]
openfl-html5: 1.0.4 1.0.5 1.1.0-beta 1.1.1-beta [1.4.2-beta]
openfl-native: 1.2.2 1.3.0 [1.4.0]
openfl-nme-compatibility: [1.0.2]
openfl-samples: 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 2.1.0 2.2.2 [3.3.1]
openfl-tools: [1.0.10] 1.0.6
openfl: 1.2.2 1.3.0 1.4.0 2.0.0 2.0.1 2.1.0 2.1.1 2.2.4 3.0.0-beta 3.0.0-beta.2
3.0.0-beta.3 3.0.6 3.1.3 3.5.2 [3.5.3]
Parsex: [1.4.0]
RedPotionEngine: [0.0.1]
spinehx: [0.2.0]
SpriterHaxeEngine: [0.8.0] 0.9.0 1.1.0 1.1.1
stablexui: 1.0.17 1.1.4 [1.1.5]
svg: 1.0.7 [1.0.8]
swf: 1.8.1 1.8.9 [2.1.6]
tilelayer - Copie: [0.0.1]
tilelayer: [0.0.1] 0.2.0
yagp: [1.1.4]

You can remove the following libraries if you want:

  • hxlibc
  • hxtools
  • lime-tools
  • openfl-html5-dom
  • openfl-html5
  • openfl-native
  • openfl-nme-compatibility
  • openfl-tools

Those are old and no longer used :smile:

Strange, I tried the sample with the same HXCPP, OpenFL and Lime releases, and it worked on the Nexus 5. What device are you having trouble with, and what OS release is installed? Thanks :slight_smile:

EDIT: Do you have Haxe 3.2 or 3.2.1 installed?

I use Haxe 3.2.1, on a Samsung galaxy tab 2 7.0 (GT-P3110) with android 4.1.2

I work with flashdevelop 5.0.2.2, on Windows 7 SP1.

I’ll try to reinstall haxe and rebuild.

just updated to Haxe 3.2.1 and am still receiving the error on our Hudl 2, running Android 5.1 ,

for me, the line causing the error is a null object reference in lime.audio.AudioBuffer.hx specifically line 130 which reads

audioBuffer.data = new UInt8Array (@:privateAccess new Bytes (data.data.length, data.data.b));

have added a trace to that line, for each of my two .ogg files, the working one, followed by the non working one - the trace results are as follows.

I/trace   (27273): Main.hx:17: line 1
I/trace   (27273): AudioBuffer.hx:130: audiobuffer = AudioBuffer
I/trace   (27273): AudioBuffer.hx:131: audiobuffer.data = null
I/trace   (27273): AudioBuffer.hx:132: data = { sampleRate => 44100, data => { length => 10985472, b =>
I/trace   (27273): AudioBuffer.hx:133: data.data = { length => 10985472, b =>
I/trace   (27273): AudioBuffer.hx:134: data.data.b =
I/trace   (27273): AudioBuffer.hx:135: data.sampleRate = 44100
I/trace   (27273): Main.hx:19: line 2
I/trace   (27273): AudioBuffer.hx:130: audiobuffer = AudioBuffer
I/trace   (27273): AudioBuffer.hx:131: audiobuffer.data = null
I/trace   (27273): AudioBuffer.hx:132: data = { sampleRate => 44100, 2
I/trace   (27273): AudioBuffer.hx:133: data.data = null

on the second .ogg, the data has a sample rate, but no data.data !, which appears to be the likely cause of the crash !

1 Like

I’m trying to figure this out, very strange

Thank you again for the “soundtest” project. I was able to get a solution!

This is a strange race condition, where things are collected before we access them in Haxe. It’s difficult to reproduce, but when it occurs (such as in your test), it’s serious trouble. I am not sure if it is compiler or platform specific, but I have seen it only with current HXCPP releases and Android with the newer r10e NDK. I don’t know if it’s related to HXCPP, or a newer GCC, or something else within the Android NDK.

Bottom-line, when we alloc_empty_object () and return it to Haxe, this is still possible to access, but if we alloc_field () an additional child object, the child object may be already collected.

It’s not perfect, but I found that if I allocate the “b” and “length” values to the same return object, instead of a child “data” field, it appears to always work within the test, and hopefully resolves this problem entirely.

This will go out in the next release, or you can try the latest Lime sources :slight_smile:

great ! sorry to have not gotten back with further testing /checking on this, but with the latest release i’m now seeing similar crashes with e.g. Assets.getBitmapData (“imageassets/bunnysheet.png”); across each of Windows, neko and android targets :confused: - so i cant just set the current versions and test any of my projects quickly to see if the sound is fixed…

What version are you using?