#2074 closed defect (fixed)
Blocking select() on Android — at Version 2
Reported by: | nanang | Owned by: | bennylp |
---|---|---|---|
Priority: | normal | Milestone: | release-2.8 |
Component: | pjsua-lib | Version: | trunk |
Keywords: | Cc: | ||
Backport to 1.x milestone: | Backported: | no |
Description (last modified by ming)
Reported that on some platforms, such as Google Pixel XL running Android 8.0, and when device is not connected to computer (via USB), select() may block much longer than the specified timeout param, for example:
pjsip-2.7.1 NDK: r10d (similar result using r15c) Device: Google Pixel XL OS: Android 8.0 Charging (USB to computer): 19:20:13.781 TTT select: n=1024, rv=0, elapsed=10, timeout=10 19:20:14.811 TTT select: n=1024, rv=0, elapsed=10, timeout=10 19:20:15.023 TTT select: n=1024, rv=1, elapsed=5, timeout=10 19:20:15.837 TTT select: n=1024, rv=0, elapsed=10, timeout=10 Not charging (or to AC -> Not USB to computer) 19:23:41.819 TTT select: n=1024, rv=0, elapsed=1959, timeout=10 19:23:41.841 TTT select: n=1024, rv=0, elapsed=10, timeout=10 19:24:09.848 TTT select: n=1024, rv=0, elapsed=26339, timeout=10 19:24:19.140 TTT select: n=1024, rv=0, elapsed=9164, timeout=10
As currently each worker thread (also by default there will be only one worker thread) polls both, network events and timer events, such long block in network poll will affect timer events, e.g: TCP/TLS transport get disconnected by server/router as keep-alive packet not delivered in timely manner.
This ticket introduces compile time setting PJSUA_SEPARATE_WORKER_FOR_TIMER which when it is set, timer heap and network events will be polled from different worker thread, i.e: one thread will be dedicated for timer heap events polling and other thread(s) will poll network events.
Thanks Sébastien Tardif for the report.
*IMPORTANT*: Despite the workaround in the ticket, it is more recommended to use the approach officially suggested by the mobile platforms (Android, Apple, Windows) instead, i.e. to completely deactivate all worker threads and shutdown or put your application in sleep mode as to consume as minimal power as possible, and rely on push notifications to wake it up when needed.
Change History (2)
comment:1 Changed 7 years ago by nanang
- Resolution set to fixed
- Status changed from new to closed
comment:2 Changed 7 years ago by ming
- Description modified (diff)
In 5712: