id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,backport_to_milestone,backported 2074,Blocking select() on Android,nanang,bennylp,"***IMPORTANT***: Further testing seems to suggest that separating worker threads doesn't improve the situation. Thus, it is recommended to use the approach officially suggested by the mobile platforms (Android, Apple, Windows) themselves, i.e. to completely deactivate all worker threads and shutdown or put your application in sleep mode, and rely on push notifications to wake it up when needed. This way, application will be able to consume as minimal power as possible. ---- 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. ",defect,closed,normal,release-2.8,pjsua-lib,trunk,fixed,,,,0