1

I've been having an issue with a game I'm writing targeting Android with HaxeFlixel and OpenFL 2.1.3. The game crashes randomly, sometimes soon after starting, sometimes after several minutes, and instantly closes the app with no message or obvious bug. For whatever reason I'm having difficulty debugging the app with an IDE attached, so I've attached logcat while running it on the device and I've narrowed it down to the following trace:

I/trace   ( 8505): Lib.hx:324: Null Object Reference
I/trace   ( 8505): Called from openfl._v2.display.Stage.__render (openfl/_v2/display/Stage.hx line 1035)
I/trace   ( 8505): Called from openfl._v2.display.DisplayObjectContainer.__broadcast (openfl/_v2/display/DisplayObjectContainer.hx line 280)
I/trace   ( 8505): Called from openfl._v2.display.DisplayObject.__broadcast (openfl/_v2/display/DisplayObject.hx line 174)
I/trace   ( 8505): Called from openfl._v2.display.DisplayObject.__dispatchEvent (openfl/_v2/display/DisplayObject.hx line 195)
I/trace   ( 8505): Called from openfl._v2.events.EventDispatcher.dispatchEvent (openfl/_v2/events/EventDispatcher.hx line 100)
I/trace   ( 8505): Called from openfl._v2.events.Listener.dispatchEvent (openfl/_v2/events/EventDispatcher.hx line 270)
I/trace   ( 8505): Called from flixel.FlxGame.onEnterFrame (flixel/FlxGame.hx line 493)
I/trace   ( 8505): Called from flixel.FlxGame.step (flixel/FlxGame.hx line 648)
I/trace   ( 8505): Called from flixel.FlxGame.update (flixel/FlxGame.hx line 696)
I/trace   ( 8505): Called from flixel.system.frontEnds.SoundFrontEnd.update (flixel/system/frontEnds/SoundFrontEnd.hx line 278)
I/trace   ( 8505): Called from flixel.group.FlxTypedGroup.update (flixel/grou
I/WindowState(  467): WIN DEATH: Window{2b71e64d u0 com.al.shb/com.al.shb.MainActivity}
W/WindowManager(  467): Force-removing child win Window{d7de13 u0 SurfaceView} from container Window{2b71e64d u0 com.al.shb/com.al.shb.MainActivity}
W/WindowManager(  467): Failed looking up window
W/WindowManager(  467): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@2038b502 does not exist
W/WindowManager(  467):     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8539)
W/WindowManager(  467):     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8530)
W/WindowManager(  467):     at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1142)
W/WindowManager(  467):     at android.os.BinderProxy.sendDeathNotice(Binder.java:551)
I/WindowState(  467): WIN DEATH: null
I/InputDispatcher(  467): Dropping event because there is no touchable window at (87, 430).
I/Zygote  (  130): Process 8505 exited cleanly (1)
I/ActivityManager(  467): Process com.al.shb (pid 8505) has died
W/ActivityManager(  467): Force removing ActivityRecord{3f0e8887 u0 com.al.shb/.MainActivity t13}: app died, no saved state

SoundFrontEnd/FlxTypedGroup would suggest that it's a problem with the group of in-game sound effects. The sounds seem to play fine and are encoded as .ogg files. It's not crashing when it tries to play any sound in particular, it's more of a random occurrence.

I cache the sounds for Android target as recommended by HaxeFlixel, but I cache them in init() in my Main class, this shouldn't be a problem:

private function setupGame():Void
{
    var stageWidth:Int = Lib.current.stage.stageWidth;
    var stageHeight:Int = Lib.current.stage.stageHeight;

    if (zoom == -1)
    {
        var ratioX:Float = stageWidth / gameWidth;
        var ratioY:Float = stageHeight / gameHeight;
        zoom = Math.min(ratioX, ratioY);
        gameWidth = Math.ceil(stageWidth / zoom);
        gameHeight = Math.ceil(stageHeight / zoom);
    }

    #if android
    FlxG.sound.cache("button");
    FlxG.sound.cache("t1");
    FlxG.sound.cache("t2");
    FlxG.sound.cache("fx");
    #end

    addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));
}

They are played using FlxG.sound.play("button").

I've also had a look in OpenFL Lib.hx to check the Null Object Reference, it would appear to be an issue with the bottom code block in the following method, however I suspect this is a red herring:

public static function rethrow (error:Dynamic):Void {   
    var event = new UncaughtErrorEvent (UncaughtErrorEvent.UNCAUGHT_ERROR, true, true, error);

    if (__uncaughtExceptionHandler != null && __uncaughtExceptionHandler (event)) {
        return;
    }

    Lib.current.loaderInfo.uncaughtErrorEvents.dispatchEvent (event);   

    if (!event.__getIsCancelled ()) {
        var message = "";
        if (error != null && error != "") {
            message = error + "";
        }

        var stack = CallStack.exceptionStack ();
        if (stack.length > 0) {
            message += CallStack.toString (stack) + "\n";
        } else {
            message += "\n";
        }

        #if (mobile && !ios)
        trace (message);
        #else
        Sys.stderr ().write (Bytes.ofString (message));
        #end
        Sys.exit (1);
    }
}

It's worth noting that if I target Flash or Windows there is no problem at all, it's only when targeting Android. The difference being that Flash and Windows use mp3 encoded files while Android uses ogg.

alundy
  • 857
  • 8
  • 22
  • Possible duplicate of [Recommended Android music format - mp3, ogg or other?](http://stackoverflow.com/questions/5430727/recommended-android-music-format-mp3-ogg-or-other) – Paul Sweatte Oct 19 '16 at 17:08
  • Android supports ogg playback. It's clear that this is not a duplicate of that question. This is a far more specific issue. – alundy Oct 20 '16 at 08:48

0 Answers0