paho.mqtt.android icon indicating copy to clipboard operation
paho.mqtt.android copied to clipboard

ANR issue

Open baole opened this issue 7 years ago • 4 comments

Please fill out the form below before submitting, thank you!

  • [x ] Bug exists Release Version 1.1.1 (Java Repository Master Branch)
  • [ ] Bug exists in Snapshot Version 1.1.2-SNAPSHOT (Android Service Repository Master Branch)
  • [ ] Bug is just in the Sample Application.

__Android API Version Bug Seen on:

__Android Version Bug Seen on:Android 4.x

Please also check that if you have found the bug in the Release version (1.1.1) that you check that it also exists in the Snapshot (1.1.2-SNAPSHOT) before raising a bug.

Description of Bug:

This happened to our app on Play store and ANR reported by Play store

Console Log output (if available):

Input dispatching timed out (Waiting because the touched window has not finished processing the input events that were previously delivered to it.)

"main" prio=5 tid=1 TIMED_WAIT
  | group="main" sCount=1 dsCount=0 obj=0x41627e40 self=0x41548828
  | sysTid=28999 nice=-6 sched=0/0 cgrp=apps handle=1073914196
  | state=S schedstat=( 0 0 0 ) utm=9971 stm=1434 core=0
  at java.lang.Object.wait (Object.java)
waiting on <0x41627f10> (a java.lang.VMThread) held by tid=1 (main)
  at java.lang.Thread.parkFor (Thread.java:1205)
  at sun.misc.Unsafe.park (Unsafe.java:325)
  at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:197)
  at android.database.sqlite.SQLiteConnectionPool.waitForConnection (SQLiteConnectionPool.java:670)
  at android.database.sqlite.SQLiteConnectionPool.acquireConnection (SQLiteConnectionPool.java:348)
  at android.database.sqlite.SQLiteSession.acquireConnection (SQLiteSession.java:894)
  at android.database.sqlite.SQLiteSession.prepare (SQLiteSession.java:586)
  at android.database.sqlite.SQLiteProgram.<init> (SQLiteProgram.java:58)
  at android.database.sqlite.SQLiteQuery.<init> (SQLiteQuery.java:37)
  at android.database.sqlite.SQLiteDirectCursorDriver.query (SQLiteDirectCursorDriver.java:44)
  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java:1314)
  at android.database.sqlite.SQLiteDatabase.queryWithFactory (SQLiteDatabase.java:1161)
  at android.database.sqlite.SQLiteDatabase.query (SQLiteDatabase.java:1032)
  at android.database.sqlite.SQLiteDatabase.query (SQLiteDatabase.java:1200)
  at org.eclipse.paho.android.service.DatabaseMessageStore.getArrivedRowCount (DatabaseMessageStore.java:216)
  at org.eclipse.paho.android.service.DatabaseMessageStore.discardArrived (DatabaseMessageStore.java:270)
  at org.eclipse.paho.android.service.MqttService.acknowledgeMessageArrival (MqttService.java:602)
  at org.eclipse.paho.android.service.MqttAndroidClient.messageArrivedAction (MqttAndroidClient.java:1574)
  at org.eclipse.paho.android.service.MqttAndroidClient.onReceive (MqttAndroidClient.java:1374)
  at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts (LocalBroadcastManager.java:297)
  at android.support.v4.content.LocalBroadcastManager.access$000 (LocalBroadcastManager.java:46)
  at android.support.v4.content.LocalBroadcastManager$1.handleMessage (LocalBroadcastManager.java:116)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:136)
  at android.app.ActivityThread.main (ActivityThread.java:5102)
  at java.lang.reflect.Method.invokeNative (Method.java)
  at java.lang.reflect.Method.invoke (Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:785)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:601)
  at dalvik.system.NativeStart.main (NativeStart.java)

Is there anything wrong that MQTT runs on main/UI thread?

baole avatar Aug 15 '17 08:08 baole

@jpwsutton,Hi, we are also getting ANR associated with this, specially if topic messaging frequency is 1 sec or less. The UI will freeze up. Is there an ETA on this fix? Thanks

naimaryan1 avatar Dec 17 '18 18:12 naimaryan1

we also encountered the same issue. Do you have any solutions?

cliangtime avatar Aug 18 '23 07:08 cliangtime

My sample:

	/**
	 * 处理收到消息的线程池
	 * @<code> messageArrivedExecutor.submit(() -> messageArrivedAction(data)); </code>
	 */
	ExecutorService messageArrivedExecutor = Executors.newSingleThreadExecutor();

in MqttAndroidClient.java onReceive(...)

L-X-J avatar Nov 29 '23 07:11 L-X-J

I've got the same issue. How do I resolve it?

abhandarkar avatar Mar 15 '24 06:03 abhandarkar