[Resolved] Works in Sim but crashes on device

Hi,

I have a game that seems to be working fine in the simulator but when I build for Android it is crashing. The crash is always at a certain point in the game when 3 objects collide and are supposed to be removed.

here is my code and trace:

I/DEBUG (20600): #00 pc 000ff760 /data/data/com.playground.beanz/lib/libcorona.so  
I/DEBUG (20600): #01 lr 818e5cf4 /data/data/com.playground.beanz/lib/libcorona.so  
I/DEBUG (20600):   
I/DEBUG (20600): code around pc:  
I/DEBUG (20600): 818ff740 e92d4010 e3530000 08bd8010 e1a00003   
I/DEBUG (20600): 818ff750 e5933000 e1a0e00f e593f008 e8bd8010   
I/DEBUG (20600): 818ff760 e5902010 e1a00001 e30d18f0 e92d4010   
I/DEBUG (20600): 818ff770 e34f1fff ebfd4fbe e3a00001 e8bd8010   
I/DEBUG (20600): 818ff780 e92d4010 e1a04000 e1a00001 e30d18f0   
I/DEBUG (20600):   
I/DEBUG (20600): code around lr:  
I/DEBUG (20600): 818e5cd4 e1a06002 ebfdb256 e5953000 e1a00005   
I/DEBUG (20600): 818e5ce4 e1a0e00f e593f030 e1a01004 eb00669a   
I/DEBUG (20600): 818e5cf4 e59f209c e3e01000 e1a00004 e08f2002   
I/DEBUG (20600): 818e5d04 ebfdb676 e1a00004 e3e01001 ebfdb274   
I/DEBUG (20600): 818e5d14 e1a01004 e5963000 e1a00006 e1a0e00f   
I/DEBUG (20600):   
I/DEBUG (20600): stack:  
I/DEBUG (20600): 47216958 002150e8   
I/DEBUG (20600): 4721695c 00000001   
I/DEBUG (20600): 47216960 002468c8   
I/DEBUG (20600): 47216964 81853178 /data/data/com.playground.beanz/lib/libcorona.so  
I/DEBUG (20600): 47216968 00000000   
I/DEBUG (20600): 4721696c 00000001   
I/DEBUG (20600): 47216970 00250010   
I/DEBUG (20600): 47216974 00000001   
I/DEBUG (20600): 47216978 001931c0   
I/DEBUG (20600): 4721697c 00000001   
I/DEBUG (20600): 47216980 00000002   
I/DEBUG (20600): 47216984 818f22dc /data/data/com.playground.beanz/lib/libcorona.so  
I/DEBUG (20600): 47216988 001931c0   
I/DEBUG (20600): 4721698c 002468c8   
I/DEBUG (20600): 47216990 df002777   
I/DEBUG (20600): 47216994 e3a070ad   
I/DEBUG (20600): #00 47216998 472169ec   
I/DEBUG (20600): 4721699c 001931c0   
I/DEBUG (20600): 472169a0 00192f18   
I/DEBUG (20600): 472169a4 818eb6d0 /data/data/com.playground.beanz/lib/libcorona.so  
I/DEBUG (20600): 472169a8 472169c0   
I/DEBUG (20600): 472169ac 472169ec   
I/DEBUG (20600): 472169b0 00192f18   
I/DEBUG (20600): 472169b4 47216a10   
I/DEBUG (20600): 472169b8 00000002   
I/DEBUG (20600): 472169bc 8190c7e0 /data/data/com.playground.beanz/lib/libcorona.so  
I/DEBUG (20600): 472169c0 00192f18   
I/DEBUG (20600): 472169c4 00192e00   
I/DEBUG (20600): 472169c8 81957330   
I/DEBUG (20600): 472169cc 00253ab8   
I/DEBUG (20600): 472169d0 472169ec   
I/DEBUG (20600): 472169d4 81904d78 /data/data/com.playground.beanz/lib/libcorona.so  
I/DEBUG (20600): 472169d8 40dfffdd   
I/DEBUG (20600): 472169dc 00000001   
D/PowerManagerService( 2694): onSensorChanged: light value: 100  
I/BootReceiver( 2694): Copying /data/tombstones/tombstone\_02 to DropBox (SYSTEM\_TOMBSTONE)  
I/DEBUG (20600): dumpstate /data/log/dumpstate\_app\_native.txt  
I/dumpstate(21137): begin  
I/dalvikvm( 2694): threadid=4: reacting to signal 3  
D/dalvikvm( 2694): GC\_FOR\_MALLOC freed 1617K, 43% free 8476K/14727K, external 11596K/11680K, paused 57ms  
E/lights ( 2694): write\_int: path /sys/devices/virtual/misc/melfas\_touchkey/brightness, value 2  
W/PowerManagerService( 2694): Timer 0x7-\>0x3|0x0  
I/PowerManagerService( 2694): Ulight 7-\>3|0  
D/PowerManagerService( 2694): setLightBrightness : mButtonLight : 0  
I/dalvikvm( 2694): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2807): threadid=4: reacting to signal 3  
I/dalvikvm( 2807): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2817): threadid=4: reacting to signal 3  
I/dalvikvm( 2817): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2826): threadid=4: reacting to signal 3  
I/dalvikvm( 2826): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2827): threadid=4: reacting to signal 3  
I/dalvikvm( 2827): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2832): threadid=4: reacting to signal 3  
I/dalvikvm( 2832): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2834): threadid=4: reacting to signal 3  
I/dalvikvm( 2834): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2850): threadid=4: reacting to signal 3  
I/dalvikvm( 2850): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2885): threadid=4: reacting to signal 3  
I/dalvikvm( 2885): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 2956): threadid=4: reacting to signal 3  
I/dalvikvm( 2956): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 3006): threadid=4: reacting to signal 3  
I/dalvikvm( 3006): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 3436): threadid=4: reacting to signal 3  
I/dalvikvm( 3436): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 5019): threadid=4: reacting to signal 3  
I/dalvikvm( 5019): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 5107): threadid=4: reacting to signal 3  
I/dalvikvm( 5107): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 6723): threadid=4: reacting to signal 3  
I/dalvikvm( 6723): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 6735): threadid=4: reacting to signal 3  
I/dalvikvm( 6735): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 6917): threadid=4: reacting to signal 3  
I/dalvikvm( 6917): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 7546): threadid=4: reacting to signal 3  
I/dalvikvm( 7546): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 7564): threadid=4: reacting to signal 3  
I/dalvikvm( 7564): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm( 7591): threadid=4: reacting to signal 3  
I/dalvikvm( 7591): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(13821): threadid=4: reacting to signal 3  
I/dalvikvm(13821): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(13835): threadid=4: reacting to signal 3  
I/dalvikvm(13835): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(13843): threadid=4: reacting to signal 3  
I/dalvikvm(13843): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(13877): threadid=4: reacting to signal 3  
I/dalvikvm(13877): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(14101): threadid=4: reacting to signal 3  
I/dalvikvm(14101): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(14484): threadid=4: reacting to signal 3  
I/dalvikvm(14484): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(16303): threadid=4: reacting to signal 3  
I/dalvikvm(16303): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(16385): threadid=4: reacting to signal 3  
I/dalvikvm(16385): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(16400): threadid=4: reacting to signal 3  
I/dalvikvm(16400): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(16461): threadid=4: reacting to signal 3  
I/dalvikvm(16461): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(16532): threadid=4: reacting to signal 3  
I/dalvikvm(16532): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(17478): threadid=4: reacting to signal 3  
I/dalvikvm(17478): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(17601): threadid=4: reacting to signal 3  
I/dalvikvm(17601): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(17714): threadid=4: reacting to signal 3  
I/dalvikvm(17714): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(18332): threadid=4: reacting to signal 3  
I/dalvikvm(18332): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(18382): threadid=4: reacting to signal 3  
I/dalvikvm(18382): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(18832): threadid=4: reacting to signal 3  
I/dalvikvm(18832): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(18894): threadid=4: reacting to signal 3  
I/dalvikvm(18894): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(19226): threadid=4: reacting to signal 3  
I/dalvikvm(19226): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(20111): threadid=4: reacting to signal 3  
I/dalvikvm(20111): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(20247): threadid=4: reacting to signal 3  
I/dalvikvm(20247): Wrote stack traces to '/data/anr/traces.txt'  
I/dalvikvm(21063): threadid=4: reacting to signal 3  
I/dalvikvm(21063): Wrote stack traces to '/data/anr/traces.txt'  
D/dalvikvm( 2956): GC\_EXPLICIT freed 1K, 53% free 2593K/5511K, external 0K/0K, paused 15ms  
D/PowerManagerService( 2694): onSensorChanged: light value: 100  
D/VoldCmdListener( 2571): asec list  
I/dumpstate(21137): done  
I/ActivityManager( 2694): Process com.playground.beanz (pid 21063) has died.  
I/WindowManager( 2694): WIN DEATH: Window{405404d0 SurfaceView paused=false}  
E/InputDispatcher( 2694): channel '4095fa38 com.playground.beanz/com.ansca.corona.CoronaActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8  
E/InputDispatcher( 2694): channel '4095fa38 com.playground.beanz/com.ansca.corona.CoronaActivity (server)' ~ Channel is unrecoverably broken and will be disposed!  
D/Zygote ( 2578): Process 21063 terminated by signal (11)  
I/WindowManager( 2694): WIN DEATH: Window{4095fa38 com.playground.beanz/com.ansca.corona.CoronaActivity paused=false}  
I/Launcher( 2850): onResume(). mIsNewIntent : false screenOff: false  
E/BulkCursor( 2850): Unable to requery because the remote process exception null  
W/BulkCursor( 2850): Remote process exception when deactivating  

[code]
function b:collision(e)
local object1 = e.target
local object2 = e.other

if(e.phase == “began”) then

if (object2.type ~= “wall”) then
if (object1.flag == true) then
timer.performWithDelay(500, preview, 1);
end
if (object2.flag == true) then
timer.performWithDelay(500, preview, 1);
end
object1.flag = false;
object2.flag = false;
if (object1.isFocus) then
object1.isFocus = false;
object2.isFocus = false;
display.getCurrentStage():setFocus(nil);
end;
end

if(object1.type == “bean” and object2.type == “bean”) then
if(object1.colour == object2.colour) then
if(#object1.touching > 0) then
inTable = false;
for k=#object1.touching, 1, -1 do
if (object1.touching[k] == object2) then
inTable = true;
end
end
if(inTable == false) then
object1.touching[#object1.touching+1] = object2;
end
else
object1.touching[1] = object2;
end

if (#object2.touching > 0) then
inTable = false;
for k=#object2.touching, 1, -1 do
if (object2.touching[k] == object1) then
inTable = true;
end
end
if(inTable == false) then
object2.touching[#object2.touching+1] = object1;
end
else
object2.touching[1] = object1;
end
end
if(#object1.touching >= 2 or #object2.touching >= 2) then
for k=#object1.touching, 1, -1 do
if (object1.touching[k] ~= nil) then
if (object1.touching[k] ~= object2) then
timer.performWithDelay(10, object1.touching[k]:pop());
end
end
end
for k=#object2.touching, 1, -1 do
if (object2.touching[k] ~= nil) then
if (object2.touching[k] ~= object1) then
timer.performWithDelay(10, object2.touching[k]:pop());
end
end
end
timer.performWithDelay(10, object1:pop());
timer.performWithDelay(10, object2:pop());
addToScore()
end
end

elseif(e.phase == “ended”) then
if(object1.colour == object2.colour) then
if (#object1.touching > 0) then
for k=#object1.touching, 1, -1 do
if (object1.touching[k] == object2) then
object1.touching[k] = nil;
end
end
end
if (#object2.touching > 0) then
for k=#object2.touching, 1, -1 do
if (object2.touching[k] == object1) then
object2.touching[k] = nil;
end
end
end
end

end
end

Are you checking that event.phase is ended before trying to remove an object? [import]uid: 52491 topic_id: 23427 reply_id: 94038[/import]

What if the event.phase never ends? [import]uid: 31694 topic_id: 23427 reply_id: 94239[/import]

If should end - you can’t remove a physics body before collision is resolved.

In the simulator I imagine this event prints errors of some kind? [import]uid: 52491 topic_id: 23427 reply_id: 94401[/import]

tried moving my call to my remove function into the phase == ended part but it made just made my code buggier and didn’t stop the crashing on device.

I get no errors in the simulator.

Did you have a chance to see that video I emailed you to see what I was trying to do? [import]uid: 31694 topic_id: 23427 reply_id: 94426[/import]

I have traced the issue to this line:

collectgarbage("collect");  

But I have also noticed that without this line I get an error that states I am trying to remove something that has already been removed. [import]uid: 31694 topic_id: 23427 reply_id: 94432[/import]

SOLVED

I changed my pop function from this:

function bean:pop()  
 if (self) then  
 for k=#beans, 1, -1 do  
 if (beans[k] == self) then   
 table.remove(beans,k);   
 end  
 end  
  
 --hide the object  
 self.isVisible = false;  
  
 --Finally remove the object  
 self:removeSelf();  
 self = nil;  
 collectgarbage("collect");  
 end  
 end  

to this:

function bean:pop() for k=#beans, 1, -1 do if (beans[k] == self) then beans[k].isVisible = false; beans[k]:removeSelf(); table.remove(beans,k); end end end [import]uid: 31694 topic_id: 23427 reply_id: 94455[/import]

Great! Pleased to hear you were able to resolve this and think it’s fantastic you posted the solution for others :slight_smile:

Peach [import]uid: 52491 topic_id: 23427 reply_id: 94674[/import]