Opened 7 years ago
Last modified 7 years ago
#2074 closed defect
Blocking select() on Android — at Initial Version
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
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.