Why am I getting: threadid=3: reacting to signal 3 and game freeze (AndEngine)?
Asked Answered
T

2

10

I'm using AndEngine to make a game that deals with a lot of moving sprites. It's inconsistant when, but eventually I get a message in the log cat (threadid=3: reacting to signal 3) and the game freezes. What does this error mean? I've narrowed down in the code where it happens (it's marked):

private void levelComplete(){
        runOnUiThread(new Runnable() {
            public void run() {
                 Toast.makeText(TestGFX5Activity.this, "Level Complete", Toast.LENGTH_SHORT).show();
            }
        });
        Log.e("Level Complete","Going to reset values");
        //Reset values
        level++;
        fillerCount = (originalNumberOfFillers + level - 1);
        areaFilled=0;
        fillAreaPercent = 0;

        //Rid scene of sprites
        for(int x=0;x<=fillerNum;x++){  
            filler[x].body.setActive(false);
            scene.detachChild(filler[x].sprite);
            filler[x].active=false;
            filler[x].scale=originalSpriteScale;
            filler[x].body.setUserData("inactive");
        }
        levelText.setText("Level: "+Integer.toString(level));
        fillersLeftText.setText("Balls left: "+Integer.toString(fillerCount));
        percentFilledText.setText("0%");
        fillerNum = -1;

        Log.e("Level Complete","values reset");

        randx = random.nextInt(650) + 25;
        randy = random.nextInt(400) + 25;
        randix = random.nextInt(10);
        randiy = random.nextInt(10);
        if(randix%2==0)
            ix = 5;
        else
            ix = -5;
        if(randiy%2==0)
            iy = 5;
        else
            iy = -5;

        Log.e("Level Complete","Creating destroyer"); //This line executes
        destroyer = new Ball(randx, randy, destroyerTR, getVertexBufferObjectManager(), ix, iy); //Code breaks here (*sometimes*)
        Log.e("Level Complete","complete"); //This line does not
    }

The weirdest thing is that the code works like 4/5 times (I can usually level up 3 or 4 times, and up to 9 times) before it crashes. I'm not sure what causes it. Anyone have any ideas?

Tetartohedral answered 2/7, 2012 at 22:49 Comment(1)
I face the same problem. How do you solve it?Teide
D
9

When an ANR condition happens, the Android Runtime send signal 3 to all dalvik VMs in order to cause them to dump their stack traces to generate the ANR report. The dump of strack trace will cause dalvik to momentarily suspend your app.

I suggest you to look on the logcat (event and main buffers) for ANRs. Also check /data/anr for the ANR traces to check what is causing the problem.

Dulcy answered 25/7, 2012 at 17:2 Comment(2)
I got the traces.txt file but I am not able to find out the reason. Can you show me some way to figure out what causes ANR using the traces.txt file? Thanks.Cacography
You need to check first the stack trace for the main thread. Check if the method on top of stack is one that can take longer to execute either because it is calling some blocking method like I/O, doing some intensive computation, trapped into a loop or infinite recursion, or even waiting for some resource that is being held by another thread like locks, monitors, DB access and whatnot.Verniavernice
T
3

By checking the /data/anr/traces.txt file, you can find whether there are dozens of threads, that may be the reason why your application is frozen.

Tanishatanitansy answered 11/6, 2014 at 17:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.