siovene / smart-home-control

A simple demo app for the Cordova OCF plugin, that interfaces with a smart home prototype
2 stars 3 forks source link

Smart home control demo could crash easily #11

Closed qiuzhong closed 7 years ago

qiuzhong commented 8 years ago

The OCF client smart-home-control v0.7.0 is built on cordova-plugin-ocf v0.6.2. It could crash easily when interacting with the OCF server side. It's not inevitable, but it's quite often to occur.

Steps

(Can't grantee to reproduce it 100%):

  1. Launch some OCF servers to create some resources(Like Buzzer, RGB LED)
  2. Launch the smart-home-control client, open "Continuous discovery" in settings, it will discover the resources
  3. Interact with the OCF resources

The attchment is part of the crash dump. smart-home-control-crashes.txt

Device:

Nexus5 Android 5.0.1 Intel Edison board flashed with Ostro image#510 (iotivity-1.1.1) SmartHome-Demo#c32b699

siovene commented 7 years ago

Can you try 0.8.0, just released? I have actually seen a crash on it too, to be honest, but the cause might be different and it looks far more stable in general.

qiuzhong commented 7 years ago

This release seems not stable either. I launched 3 OCF servers (Ostro image 519 with iotivity-node 1.1.1-3) and started this release app, it didn't last long (less than 2 minutes) even in the idle state. In the adb logcat, here is part of the crash log:

D/CordovaPluginOCF(27566): ==========================================================
D/OIC-JNI (27566): OcResource_get
D/OIC-JNI (27566): OnEventListener: new listener
D/OcfPlugin(27566): Executing Cordova action: getResourceUpdates
W/libc    (27566): pthread_create failed: couldn't allocate 1040384-byte stack: Operation not permitted
W/libc    (27566): pthread_create failed: couldn't allocate 1040384-byte stack: Operation not permitted
W/libc    (27566): pthread_create failed: couldn't allocate 1040384-byte stack: Operation not permitted
F/libc    (27566): Fatal signal 6 (SIGABRT), code -6 in tid 27675 (pool-1-thread-2)
W/debuggerd_real(  442): type=1400 audit(0.0:76): avc: denied { ptrace } for scontext=u:r:init:s0 tcontext=u:r:untrusted_app:s0 tclass=process
W/debuggerd_real(  442): type=1400 audit(0.0:77): avc: denied { sigstop } for scontext=u:r:init:s0 tcontext=u:r:untrusted_app:s0 tclass=process
I/DEBUG   (  442): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  442): Build fingerprint: 'google/hammerhead/hammerhead:5.0.1/LRX22C/1602158:user/release-keys'
I/DEBUG   (  442): Revision: '11'
I/DEBUG   (  442): ABI: 'arm'
I/DEBUG   (  442): pid: 27566, tid: 27675, name: pool-1-thread-2  >>> com.intel.otc.cordova.SmartHomeControl <<<
I/DEBUG   (  442): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
I/DEBUG   (  442):     r0 00000000  r1 00006c1b  r2 00000006  r3 00000000
I/DEBUG   (  442):     r4 85887db8  r5 00000006  r6 00000000  r7 0000010c
I/DEBUG   (  442):     r8 07ec0920  r9 a3b45a88  sl b6ebc2c5  fp 85887db0
I/DEBUG   (  442):     ip 00006c1b  sp 85887d10  lr b6ebcaf9  pc b6edfc24  cpsr 600f0010
I/DEBUG   (  442): 
I/DEBUG   (  442): backtrace:
I/DEBUG   (  442):     #00 pc 00039c24  /system/lib/libc.so (tgkill+12)
I/DEBUG   (  442):     #01 pc 00016af5  /system/lib/libc.so (pthread_kill+52)
I/DEBUG   (  442):     #02 pc 00017707  /system/lib/libc.so (raise+10)
I/DEBUG   (  442):     #03 pc 00013f75  /system/lib/libc.so (__libc_android_abort+36)
I/DEBUG   (  442):     #04 pc 00012a3c  /system/lib/libc.so (abort+4)
I/DEBUG   (  442):     #05 pc 0004ecef  /data/app/com.intel.otc.cordova.SmartHomeControl-1/lib/arm/libgnustl_shared.so (__gnu_cxx::__verbose_terminate_handler()+226)
I/DEBUG   (  442):     #06 pc 0004d74d  /data/app/com.intel.otc.cordova.SmartHomeControl-1/lib/arm/libgnustl_shared.so (__cxxabiv1::__terminate(void (*)())+4)
I/DEBUG   (  442):     #07 pc 0004d7c1  /data/app/com.intel.otc.cordova.SmartHomeControl-1/lib/arm/libgnustl_shared.so (std::terminate()+8)
I/DEBUG   (  442):     #08 pc 00091277  /data/app/com.intel.otc.cordova.SmartHomeControl-1/lib/arm/libgnustl_shared.so (execute_native_thread_routine+126)
I/DEBUG   (  442):     #09 pc 000162e3  /system/lib/libc.so (__pthread_start(void*)+30)
I/DEBUG   (  442):     #10 pc 000142d3  /system/lib/libc.so (__start_thread+6)

Test device is Nexus5 Android 5.0.1

qiuzhong commented 7 years ago

The app (smart-home-control-0.8.0.apk) crashed on Android 6.0+ devices when the "Continuous discovery" switch was on. Here is the results on some devices:

Device Android version Crashed?
Nexus 5 5.0.1 No
Nexus 5 6.0.1 Yes
Nexus 6P 6.0 Yes
Nexus 9 5.1.1 No
Nexus 9 7.0 Yes

Here is part of the captured log when the app was crashing:

01-11 13:02:10.102  6564  6657 D OcfPlugin: Executing Cordova action: setBackend
01-11 13:02:10.118  6564  6657 W System.err: java.lang.UnsatisfiedLinkError: dlopen failed: library "./obj/local/armeabi-v7a/liboc.so" not found
01-11 13:02:10.119  6564  6657 W System.err:    at java.lang.Runtime.loadLibrary0(Runtime.java:977)
01-11 13:02:10.119  6564  6657 W System.err:    at java.lang.System.loadLibrary(System.java:1530)
01-11 13:02:10.119  6564  6657 W System.err:    at org.iotivity.base.OcPlatform.<clinit>(OcPlatform.java:48)
01-11 13:02:10.119  6564  6657 W System.err:    at org.iotivity.base.OcPlatform.Configure(OcPlatform.java:92)
01-11 13:02:10.119  6564  6657 W System.err:    at com.intel.cordova.plugin.ocf.OcfBackendIotivity.<init>(OcfBackendIotivity.java:150)
01-11 13:02:10.119  6564  6657 W System.err:    at com.intel.cordova.plugin.ocf.OcfPlugin.setBackend(OcfPlugin.java:28)
01-11 13:02:10.119  6564  6657 W System.err:    at com.intel.cordova.plugin.ocf.OcfPlugin.execute(OcfPlugin.java:80)
01-11 13:02:10.119  6564  6657 W System.err:    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
01-11 13:02:10.119  6564  6657 W System.err:    at org.apache.cordova.PluginManager.exec(PluginManager.java:133)
01-11 13:02:10.119  6564  6657 W System.err:    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
01-11 13:02:10.119  6564  6657 W System.err:    at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
01-11 13:02:10.119  6564  6657 W System.err:    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
01-11 13:02:10.119  6564  6657 W System.err:    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:39)
01-11 13:02:10.119  6564  6657 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
01-11 13:02:10.119  6564  6657 W System.err:    at android.os.Looper.loop(Looper.java:154)
01-11 13:02:10.119  6564  6657 W System.err:    at android.os.HandlerThread.run(HandlerThread.java:61)
01-11 13:02:10.497  6564  6657 D OcfPlugin: Executing Cordova action: findResources
01-11 13:02:10.501  6564  6674 E AndroidRuntime: FATAL EXCEPTION: pool-1-thread-2
01-11 13:02:10.501  6564  6674 E AndroidRuntime: Process: com.intel.otc.cordova.SmartHomeControl, PID: 6564
01-11 13:02:10.501  6564  6674 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'void com.intel.cordova.plugin.ocf.OcfBackendInterface.findResources(org.json.JSONArray, org.apache.cordova.CallbackContext)' on a null object reference
01-11 13:02:10.501  6564  6674 E AndroidRuntime:    at com.intel.cordova.plugin.ocf.OcfPlugin$1.run(OcfPlugin.java:39)
01-11 13:02:10.501  6564  6674 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
01-11 13:02:10.501  6564  6674 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
01-11 13:02:10.501  6564  6674 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:761)
01-11 13:02:10.506   622  1510 W ActivityManager:   Force finishing activity com.intel.otc.cordova.SmartHomeControl/.MainActivity
ghost commented 7 years ago

Any chance to get this fixed for Android 6.x? Thanks :)

siovene commented 7 years ago

I'll look into it.

qiuzhong commented 7 years ago

I googled the crash error information

java.lang.UnsatisfiedLinkError: dlopen failed: library "./obj/local/armeabi-v7a/liboc.so" not found

and found a post to explain this crash. https://code.google.com/p/android/issues/detail?id=175589

According to the explanation, it's about the android-targetSdkVersion configuration. My temporary workaround is to downgrade the android-targetSdkVersion to 22 in config.xml.

It works for me. The rebuilt app didn't crash when I turned the "Continuous discovery" swicth on.

siovene commented 7 years ago

v0.8.1 fixes the dlopen issue for Android 6+ but keeping the bug open because of the memory related crash that this issue originally reported.

ghost commented 7 years ago

Version 0.8.1 is behaving better in that it will launch and sensor discovery is functional for a short little while before the app crashes. I installed version 0.8.1 on an Android 5.1.1 tablet. Using this version I can't control sensor devices using the app.

siovene commented 7 years ago

Just a quick update to let you know that I found the cause of the crash. It's a bit tricky to fix but I think I can do it.

ghost commented 7 years ago

That's good news. Looking forward to trying the new version tomorrow.

qiuzhong commented 7 years ago

@uhofemei, some sensors like buzzer and rgb led may not work (see issues/12 and issue#13) But I tried two sensors (led and fan) on a Nexus 9 tablet (Android 5.1.1), and it worked well for v0.8.1.