MsgBox2 causes android.util.AndroidRuntimeException

thedesolatesoul

Expert
Licensed User
Longtime User
Some of my code runs fine on a Froyo Emulator, but on ICS 4.0.4 (CM9 Nightly) I get the following exception.

From what I have read so far it seems that the same message is being posted twice in the message queue.

As download/upload transfers are happening in the background (with a possible timer running too), I show a messagebox to confirm deleting download history. At that point this exception is generated:
B4X:
android.util.AndroidRuntimeException: { what=0 when=-12h1m24s814ms } This message is already in use.
   at android.os.MessageQueue.enqueueMessage(MessageQueue.java:187)
   at android.os.Handler.sendMessageAtTime(Handler.java:473)
   at android.os.Handler.sendMessageDelayed(Handler.java:446)
   at android.os.Handler.sendMessage(Handler.java:383)
   at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:172)
   at anywheresoftware.b4a.Msgbox.msgbox(Msgbox.java:127)
   at anywheresoftware.b4a.keywords.Common.Msgbox2(Common.java:404)
   at com.maximus.dropboxexample.main._clearalltransfers(main.java:1286)
   at com.maximus.dropboxexample.main._ab_itemclicked(main.java:328)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:89)
   at de.amberhome.SimpleActionBar.ActionBar$Action.select(ActionBar.java:1683)
   at de.amberhome.SimpleActionBar.ActionBar$2.onClick(ActionBar.java:262)
   at android.view.View.performClick(View.java:3511)
   at android.view.View$PerformClick.run(View.java:14105)
   at android.os.Handler.handleCallback(Handler.java:605)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4424)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
   at dalvik.system.NativeStart.main(Native Method)
Later on I also get this one, but I think its harmless:
B4X:
libcore.io.ErrnoException: kill failed: ESRCH (No such process)
   at libcore.io.Posix.kill(Native Method)
   at libcore.io.ForwardingOs.kill(ForwardingOs.java:77)
   at java.lang.ProcessManager$ProcessImpl.destroy(ProcessManager.java:257)
   at anywheresoftware.b4a.phone.Phone$LogCat.LogCatStop(Phone.java:758)
   at anywheresoftware.b4a.b4abridge.service1._stoplogcat(service1.java:510)
   at anywheresoftware.b4a.b4abridge.service1._streams_newdata(service1.java:565)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:136)
   at anywheresoftware.b4a.BA$2.run(BA.java:244)
   at android.os.Handler.handleCallback(Handler.java:605)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4424)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
   at dalvik.system.NativeStart.main(Native Method)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Android 4.0.3 changes the way that internal messages are handled. I'm familiar with a different issue which is probably related to this one.
The fix might require a library update.

Can you create a small project that demonstrates this issue?
It should be something simple with a msgbox shown inside the ActionBar click event.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
It took me a while to reproduce this. Nothing to do with the action bar.
It actually crashes with HttpUtils.
Here is a small example that crashes on ICS for me.
Press the 'Start Timer' button, and then immediately press ''Show Messagebox'.
The unfiltered logs will show the exception.

Also, Erel I am using B4A 1.6 (Core library version 1.57)

Test Device: ICS 4.0.4 (CM9 Nightly) on a Samsung Galaxy S

For now, I am thinking of a non-modal messagebox as a workaround, which raises an event on dismissal.
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
Erel, I'm running android 4.0.3 and b4a 1.8.

What do I need to do to test this?

Regards, Ricky
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
I also cannot reproduce this on B4A 1.9 and Android 4.0.4 on a Motorola Xoom (yes Erel, I did check that I was using the 1.9 jars and that my simple test still crashed). Maybe it's because you are using B4A 1.6 instead of the latest 1.9
Hi Andrew,
I dont completely understand what you are saying. Are you saying it crashes on on B4A 1.6 and not 1.9 (regardless of the jar files)?
Maybe Erel knows if the Msgbox handling changed during these versions.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Okay thanks.
In hindsight, I see I didnt upload a very good example because it requires you to press the second button very quickly after the first one. (The first button kicks off a couple of downloads, and getting the messagebox in between, stalling the hc_Response messages makes the problem happen).
Maybe I should have added a timer on the first button for the Msgbox.
I will try to update the example again later today, if there are no other updates regarding the issue.
 
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Hello,

Picked up an old project and the MsgBox2 crashes on my 4.0.3 device.
No problem on my old 2.2 device.
See the included test.

Thanks in advance,
Helen.
 

Attachments

  • TestMsgBox2.zip
    8.4 KB · Views: 150
Upvote 0

RadCoder

Member
Licensed User
Longtime User
I seem to have a similiar problem on my SIII running 4.0.4

I have datacontroller class using httputils2 to fectch a bunch of data, then the controller class notifies the main activity when data is ready and the main activity updates the UI. Everything works fine on Jellybean , froyo and gingerbread. On my siii running ICS , google maps keeps crashing? Im not using any location based api's. The unfiltered logs show the following

libcore.io.ErrnoException: kill failed: ESRCH (No such process)
at libcore.io.Posix.kill(Native Method)
at libcore.io.ForwardingOs.kill(ForwardingOs.java:77)
at java.lang.ProcessManager$ProcessImpl.destroy(ProcessManager.java:257)
at anywheresoftware.b4a.phone.Phone$LogCat.LogCatStop(Phone.java:758)
at anywheresoftware.b4a.phone.Phone$LogCat.LogCatStart(Phone.java:703)
at anywheresoftware.b4a.b4abridge.service1._startlogcat(service1.java:614)
at anywheresoftware.b4a.b4abridge.service1._streams_newdata(service1.java:678)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at anywheresoftware.b4a.BA$3.run(BA.java:301)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4517)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
getActualApplicationStateEnabled() : true
Failed to destroy process 6300
libcore.io.ErrnoException: kill failed: ESRCH (No such process)
at libcore.io.Posix.kill(Native Method)
at libcore.io.ForwardingOs.kill(ForwardingOs.java:77)
at java.lang.ProcessManager$ProcessImpl.destroy(ProcessManager.java:257)
at anywheresoftware.b4a.phone.Phone$LogCat$1.run(Phone.java:741)


The shortly after the maps force close pops up while in my app, and it keep popping up... which is absolutely baffling

FATAL EXCEPTION: NetworkLocationCallbackRunner
java.lang.NullPointerException
at com.google.googlenav.common.io.protocol.ProtoBuf.getInt(SourceFile:228)
at com.google.android.location.e.e.b(SourceFile:196)
at com.google.android.location.b.f.a(SourceFile:395)
at com.google.android.location.b.b.a(SourceFile:167)
at com.google.android.location.p.d(SourceFile:268)
at com.google.android.location.os.real.c$c.handleMessage(SourceFile:358)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at com.google.android.location.os.real.c$f.run(SourceFile:822)
at java.lang.Thread.run(Thread.java:856)
 
Upvote 0
Top