Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 583
rphello101 Avatar asked Jul 02 '12 22:07

rphello101


2 Answers

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.

like image 148
Zephyr Avatar answered Nov 15 '22 10:11

Zephyr


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.

like image 9
André Oriani Avatar answered Nov 15 '22 10:11

André Oriani