Why am I getting: threadid = 3: responds to signal 3 and freezing the game (AndEngine)?

I use AndEngine to make a game that deals with a lot of moving sprites. This is inconsistent when, but in the end I get a message in the cat log (threadid = 3: reaction to signal 3), and the game freezes. What does this error mean? I narrowed down in the code where this happens (it is 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 strangest thing is that the code works like 4/5 times (usually I can go up 3 or 4 times and up to 9 times) before it works. I'm not sure what causes it. Does anyone have any ideas?

+6
source share
2 answers

When an ANR condition occurs, the Android 3 Runtime send signal for all dalvik virtual machines to force them to reset stack traces to generate an ANR report. Resetting the strack trace will cause dalvik to pause your application instantly.

I suggest you look at logcat (event and main buffers) for ANR. Also check / data / anr for ANR traces to see what causes the problem.

+6
source

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

+1
source

Source: https://habr.com/ru/post/919536/


All Articles