-
Bug
-
Resolution: Incomplete
-
P1: Critical
-
None
-
5.10.1
-
* Qt 5.10.1
* Android 8.0.0 armv7
* Android 8.1.0 x86 (emulator)
* NDK Version r16.b
* SDK Version 26.1.1
* Build using Android Platform 27 r01
* Tried target SKDs 27, 26 and 23
When trying to create an very simple android service, the service will never get past the onCreate method and thus is killed after a timeout of 5 seconds.
Relevant lines from the log (full log attached):
03-24 18:26:26.810 18928 18945 E TestService: about to create 03-24 18:26:26.822 1612 6516 I ActivityManager: Start proc 19102:de.skycoder42.servicetest:extra_process/u0a91 for service de.skycoder42.servicetest/.TestService 03-24 18:26:26.839 19102 19102 E TestService: before create 03-24 18:26:26.844 19102 19102 W System : ClassLoader referenced unknown path: 03-24 18:26:26.845 19102 19102 I QtCore : Start 03-24 18:26:26.859 19102 19102 I Qt : qt start 03-24 18:26:26.862 19102 19102 D : (null):0 ((null)): QML debugging is enabled. Only use this in a safe environment. 03-24 18:26:26.864 19102 19121 D : HostConnection::get() New Host Connection established 0xe58ef580, tid 19121 03-24 18:26:46.835 1612 1627 W ActivityManager: Timeout executing service: ServiceRecord{8fb4487 u0 de.skycoder42.servicetest/.TestService} 03-24 18:26:46.846 1612 1627 I zygote : libdebuggerd_client: started dumping process 19102 03-24 18:26:46.846 1496 1496 I /system/bin/tombstoned: registered intercept for pid 19102 and type kDebuggerdJavaBacktrace 03-24 18:26:46.846 19102 19109 I zygote : Thread[3,tid=19109,WaitingInMainSignalCatcherLoop,Thread*=0xed1d9c00,peer=0x14bc1938,"Signal Catcher"]: reacting to signal 3 03-24 18:26:46.858 1496 1496 I /system/bin/tombstoned: received crash request for pid 19102 03-24 18:26:46.858 1496 1496 I /system/bin/tombstoned: found intercept fd 512 for pid 19102 and type kDebuggerdJavaBacktrace 03-24 18:26:46.859 1612 1627 I zygote : libdebuggerd_client: done dumping process 19102 03-24 18:26:46.859 1612 1627 E ActivityManager: ANR in de.skycoder42.servicetest:extra_process 03-24 18:26:46.859 1612 1627 E ActivityManager: PID: 19102 03-24 18:26:46.859 1612 1627 E ActivityManager: Reason: executing service de.skycoder42.servicetest/.TestService 03-24 18:26:46.896 1612 1874 W ActivityManager: Scheduling restart of crashed service de.skycoder42.servicetest/.TestService in 40130ms 03-24 18:26:46.895 1612 1629 W zygote : kill(-19102, 9) failed: No such process 03-24 18:26:46.897 1496 1496 W /system/bin/tombstoned: crash socket received short read of length 0 (expected 12) 03-24 18:26:46.935 1612 1629 W zygote : kill(-19102, 9) failed: No such process 03-24 18:26:46.935 1612 1629 I zygote : Successfully killed process cgroup uid 10091 pid 19102 in 75ms
Edit:
So I played around a little and it seems that executing the onCreate of the service delegte in a seperate Thread serves as simple workaround. Not shure if this has any sideeffects, but at least it makes the service usable again. Code:
public class WorkaroundService extends QtService { private class ServiceCommand implements Runnable { @Override public void run() { WorkaroundService.this.createQt(); } } private Thread runThread; @Override public void onCreateHook() { runThread = new Thread(new ServiceCommand()); runThread.start(); } public void createQt() { super.onCreateHook(); // the following is never executed Log.i("WorkaroundService", "super.onCreateHook() finally returned"); } }