Pushwoosh / pushwoosh-appcelerator-titanium

Other
33 stars 16 forks source link

Android crashes when app is closed by hitting the back button #40

Closed rborn closed 7 years ago

rborn commented 7 years ago

Hi, I'm using the last version of the module, and Ti.SDK 6.0.3.

How to reproduce:

I tried to have a look at the module's code and it seems that the crash happens because on the second start the app tries to send success multiple times.

This is important for us, we have lot of complains from the users, so could you please have a look? Thank you!

Crash log:

04-20 14:55:22.392: D/PushnotificationsModule(21470): (main) [128,449] Push: ACTIVITY CREATED
04-20 14:55:22.402: D/PushnotificationsModule(21470): (main) [11,460] Push: ACTIVITY STARTED
04-20 14:55:22.402: I/TiRootActivity(21470): (main) [0,0] checkpoint, on root activity resume. activity = info.rborn.mst.MotorsportTotalComActivity@442ac690
04-20 14:55:22.402: D/PushnotificationsModule(21470): (main) [1,1] Push: ACTIVITY RESUMED: 1
04-20 14:55:22.402: D/PushnotificationsModule(21470): (main) [0,1] Push: unregistering receivers
04-20 14:55:22.402: D/PushnotificationsModule(21470): (main) [1,2] Push: finished unregistering receivers
04-20 14:55:22.402: D/PushnotificationsModule(21470): (main) [0,2] Push: register receivers
04-20 14:55:22.402: D/PushnotificationsModule(21470): (main) [2,4] Push: finished registering receivers
04-20 14:55:22.472: I/Timeline(21470): Timeline: Activity_idle id: android.os.BinderProxy@442abde8 time:99940241
04-20 14:55:22.472: I/ActivityManager(786): Displayed info.rborn.mst/.MotorsportTotalComActivity: +544ms
04-20 14:55:22.472: I/Timeline(786): Timeline: Activity_windows_visible id: ActivityRecord{422849f0 u0 info.rborn.mst/.MotorsportTotalComActivity t152} time:99940248
04-20 14:55:22.692: D/ti.ga(21470): (KrollRuntimeThread) [286,290] setTrackUncaughtExceptions is only available on iOS
04-20 14:55:22.702: D/DfpModule(21470): (KrollRuntimeThread) [13,303] module instantiated
04-20 14:55:22.992: D/PushnotificationsModule(21470): (KrollRuntimeThread) [287,590] Push: create module
04-20 14:55:22.992: D/PushnotificationsModule(21470): (KrollRuntimeThread) [1,591] Push: init activity!
04-20 14:55:22.992: D/PushnotificationsModule(21470): (KrollRuntimeThread) [4,595] initialize called
04-20 14:55:22.992: D/PushnotificationsModule(21470): (KrollRuntimeThread) [0,595] Push: unregistering receivers
04-20 14:55:22.992: D/PushnotificationsModule(21470): (KrollRuntimeThread) [0,595] Push: finished unregistering receivers
04-20 14:55:22.992: D/PushnotificationsModule(21470): (KrollRuntimeThread) [1,596] Push: register receivers
04-20 14:55:22.992: D/PushnotificationsModule(21470): (KrollRuntimeThread) [1,597] Push: finished registering receivers
04-20 14:55:23.002: V/Pushwoosh(21470): [PushRegistrarGCM] number of receivers for info.rborn.mst: 4
04-20 14:55:23.002: V/Pushwoosh(21470): [PushRegistrarGCM] Found 1 receivers for action com.google.android.c2dm.intent.RECEIVE
04-20 14:55:23.012: W/Pushwoosh(21470): [a] No android.permission.BROADCAST_STICKY. Reverting to simple broadcast
04-20 14:55:23.012: D/PushnotificationsModule(21470): (main) [17,614] Push: register broadcast received
04-20 14:55:23.012: D/PushnotificationsModule(21470): (main) [0,614] CHECK MESSAGE: push register
04-20 14:55:23.012: D/PushnotificationsModule(21470): (main) [1,615] Push: register broadcast received
04-20 14:55:23.012: D/PushnotificationsModule(21470): (main) [0,615] CHECK MESSAGE: push register
04-20 14:55:23.012: D/IntentReceiver(21470): (main) [0,615] RECEIVE: info.rborn.mst.com.pushwoosh.REGISTER_BROAD_CAST_ACTION
04-20 14:55:23.242: I/TiAPI(21470):  [pullToRefresh] is missing required Ti.UI.ListView or Ti.UI.TableView or de.marcelpociot.CollectionView
04-20 14:55:23.242: I/TiAPI(21470):      as first child element or add listview in controller with setListView method
04-20 14:55:23.362: I/TiAPI(21470):  [pullToRefresh] is missing required Ti.UI.ListView or Ti.UI.TableView or de.marcelpociot.CollectionView
04-20 14:55:23.362: I/TiAPI(21470):      as first child element or add listview in controller with setListView method
04-20 14:55:23.502: I/TiAPI(21470):  [pullToRefresh] is missing required Ti.UI.ListView or Ti.UI.TableView or de.marcelpociot.CollectionView
04-20 14:55:23.502: I/TiAPI(21470):      as first child element or add listview in controller with setListView method
04-20 14:55:24.002: D/Pushwoosh(21470): [RequestManager] Try To send: applicationOpen
04-20 14:55:24.032: I/Timeline(21470): Timeline: Activity_launch_request id:info.rborn.mst time:99941806
04-20 14:55:24.032: I/ActivityManager(786): START u0 {cmp=info.rborn.mst/org.appcelerator.titanium.TiActivity (has extras)} from pid 21470
04-20 14:55:24.042: D/PushnotificationsModule(21470): (main) [1030,1645] Push: ACTIVITY PAUSED: 0
04-20 14:55:24.042: D/PushnotificationsModule(21470): (main) [0,1645] Push: unregistering receivers
04-20 14:55:24.042: D/PushnotificationsModule(21470): (main) [1,1646] Push: finished unregistering receivers
04-20 14:55:24.042: D/PushnotificationsModule(21470): (main) [0,1646] Push: ACTIVITY PAUSED: -1
04-20 14:55:24.042: D/PushnotificationsModule(21470): (main) [0,1646] Push: unregistering receivers
04-20 14:55:24.042: D/PushnotificationsModule(21470): (main) [0,1646] Push: finished unregistering receivers
04-20 14:55:24.042: D/PushnotificationsModule(21470): (main) [1,1647] Push: on pause
04-20 14:55:24.062: W/TiAPI(21470):  ================================= pushHelper ================================================
04-20 14:55:24.062: W/TiAPI(21470):  Ti.Network.remoteNotificationsEnabled undefined
04-20 14:55:24.062: W/TiAPI(21470):  Ti.Network.remoteNotificationTypes undefined
04-20 14:55:24.062: W/TiAPI(21470):   
04-20 14:55:24.062: A/libc(21470): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 21508 (KrollRuntimeThr)
04-20 14:55:24.072: D/PushnotificationsModule(21470): (main) [23,1670] Push: ACTIVITY CREATED
04-20 14:55:24.072: D/PushnotificationsModule(21470): (main) [0,1670] Push: ACTIVITY CREATED
04-20 14:55:24.082: D/TripviDrawer(21470): initializing left drawer
04-20 14:55:24.172: I/DEBUG(224): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-20 14:55:24.172: I/DEBUG(224): Build fingerprint: 'oneplus/bacon/A0001:4.4.4/KTU84Q/XNPH05Q:user/release-keys'
04-20 14:55:24.172: I/DEBUG(224): Revision: '0'
04-20 14:55:24.172: I/DEBUG(224): pid: 21470, tid: 21508, name: KrollRuntimeThr  >>> info.rborn.mst <<<
04-20 14:55:24.172: I/DEBUG(224): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
04-20 14:55:24.302: I/DEBUG(224):     r0 00000000  r1 00000083  r2 77608121  r3 00000003
04-20 14:55:24.302: I/DEBUG(224):     r4 00000000  r5 6f926a50  r6 75ea4680  r7 00000000
04-20 14:55:24.312: I/DEBUG(224):     r8 75ea4654  r9 75ea4690  sl 7754f899  fp 75ea46f4
04-20 14:55:24.312: I/DEBUG(224):     ip 77554ef4  sp 75ea4630  lr 7754e711  pc 7642187c  cpsr 600b0010
04-20 14:55:24.312: I/DEBUG(224):     d0  41efffffffe00000  d1  0000000000000000
04-20 14:55:24.312: I/DEBUG(224):     d2  1a000004e3500000  d3  e5933003e59f302c
04-20 14:55:24.312: I/DEBUG(224):     d4  0a000000e3130001  d5  e49d0004ea000002
04-20 14:55:24.312: I/DEBUG(224):     d6  e59ff014e49d3004  d7  e1a01003e28dd008
04-20 14:55:24.312: I/DEBUG(224):     d8  0000000000000000  d9  0000000000000000
04-20 14:55:24.312: I/DEBUG(224):     d10 0000000000000000  d11 0000000000000000
04-20 14:55:24.312: I/DEBUG(224):     d12 0000000000000000  d13 0000000000000000
04-20 14:55:24.312: I/DEBUG(224):     d14 0000000000000000  d15 0000000000000000
04-20 14:55:24.312: I/DEBUG(224):     d16 6f6d796e6f6e6128  d17 74636e7566207375
04-20 14:55:24.312: I/DEBUG(224):     d18 6573756163656220  d19 7463612065687420
04-20 14:55:24.312: I/DEBUG(224):     d20 7369207974697669  d21 20646563726f6620
04-20 14:55:24.312: I/DEBUG(224):     d22 7274736564206f74  d23 6e4120796220796f
04-20 14:55:24.312: I/DEBUG(224):     d24 0000000000000000  d25 ffffffffffffffff
04-20 14:55:24.312: I/DEBUG(224):     d26 4034840000000000  d27 4014000000000000
04-20 14:55:24.312: I/DEBUG(224):     d28 c0059998b8000000  d29 bce73333a4000000
04-20 14:55:24.312: I/DEBUG(224):     d30 4024000000000000  d31 4000000000000000
04-20 14:55:24.312: I/DEBUG(224):     scr 22000011
04-20 14:55:24.312: I/DEBUG(224): backtrace:
04-20 14:55:24.312: I/DEBUG(224):     #00  pc 0039a87c  /data/app-lib/info.rborn.mst-2/libkroll-v8.so (v8::Object::InternalFieldCount()+4)
04-20 14:55:24.312: I/DEBUG(224):     #01  pc 0000470d  /data/app-lib/info.rborn.mst-2/libcom.pushwoosh.module.so (titanium::JavaObject::isJavaObject(v8::Local<v8::Object>)+2)
04-20 14:55:24.312: I/DEBUG(224):     #02  pc 0000471f  /data/app-lib/info.rborn.mst-2/libcom.pushwoosh.module.so (titanium::Proxy::unwrap(v8::Local<v8::Object>)+4)
04-20 14:55:24.312: I/DEBUG(224):     #03  pc 00005917  /data/app-lib/info.rborn.mst-2/libcom.pushwoosh.module.so (com::pushwoosh::module::PushnotificationsModule::getPushToken(v8::FunctionCallbackInfo<v8::Value> const&)+126)
04-20 14:55:24.312: I/DEBUG(224):     #04  pc 003b7620  /data/app-lib/info.rborn.mst-2/libkroll-v8.so (v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&))+136)
04-20 14:55:24.312: I/DEBUG(224):     #05  pc 00408028  /data/app-lib/info.rborn.mst-2/libkroll-v8.so
04-20 14:55:24.312: I/DEBUG(224):     #06  pc 00408698  /data/app-lib/info.rborn.mst-2/libkroll-v8.so
04-20 14:55:24.312: I/DEBUG(224):     #07  pc 00000098  <unknown>
04-20 14:55:24.312: I/DEBUG(224): stack:
04-20 14:55:24.312: I/DEBUG(224):          75ea45f0  715ad788  [anon:libc_malloc]
04-20 14:55:24.312: I/DEBUG(224):          75ea45f4  7754e839  /data/app-lib/info.rborn.mst-2/libcom.pushwoosh.module.so (com::pushwoosh::module::PushnotificationsModule::getProxyTemplate(v8::Isolate*)+28)
04-20 14:55:24.312: I/DEBUG(224):          75ea45f8  75ea4634  [stack:21508]
04-20 14:55:24.312: I/DEBUG(224):          75ea45fc  75ea4708  [stack:21508]
04-20 14:55:24.312: I/DEBUG(224):          75ea4600  770911a1  
04-20 14:55:24.312: I/DEBUG(224):          75ea4604  715ad7ac  [anon:libc_malloc]
04-20 14:55:24.312: I/DEBUG(224):          75ea4608  75ea46fc  [stack:21508]
04-20 14:55:24.312: I/DEBUG(224):          75ea460c  767bc5e4  /data/app-lib/info.rborn.mst-2/libkroll-v8.so (v8::internal::JSReceiver::DefineOwnProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyDescriptor*, v8::internal::Object::ShouldThrow)+112)
04-20 14:55:24.312: I/DEBUG(224):          75ea4610  00000000  
04-20 14:55:24.312: I/DEBUG(224):          75ea4614  75ea4708  [stack:21508]
04-20 14:55:24.312: I/DEBUG(224):          75ea4618  770911a1  
04-20 14:55:24.312: I/DEBUG(224):          75ea461c  715a0101  [anon:libc_malloc]
04-20 14:55:24.312: I/DEBUG(224):          75ea4620  75ea46fc  [stack:21508]
04-20 14:55:24.312: I/DEBUG(224):          75ea4624  767c85b8  /data/app-lib/info.rborn.mst-2/libkroll-v8.so (v8::internal::JSReceiver::DefineProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>)+264)
04-20 14:55:24.312: I/DEBUG(224):          75ea4628  00000000  
04-20 14:55:24.312: I/DEBUG(224):          75ea462c  767b42a4  /data/app-lib/info.rborn.mst-2/libkroll-v8.so (v8::internal::Object::ArraySpeciesConstructor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>)+340)
04-20 14:55:24.312: I/DEBUG(224):     #00  75ea4630  00000003  
04-20 14:55:24.312: I/DEBUG(224):          75ea4634  00000000  
04-20 14:55:24.312: I/DEBUG(224):          75ea4638  6f926a50  [anon:libc_malloc]
04-20 14:55:24.312: I/DEBUG(224):          75ea463c  7754e711  /data/app-lib/info.rborn.mst-2/libcom.pushwoosh.module.so (titanium::JavaObject::isJavaObject(v8::Local<v8::Object>)+6)
04-20 14:55:24.312: I/DEBUG(224):     #01  75ea4640  00000003  
04-20 14:55:24.312: I/DEBUG(224):          75ea4644  7754e723  /data/app-lib/info.rborn.mst-2/libcom.pushwoosh.module.so (titanium::Proxy::unwrap(v8::Local<v8::Object>)+8)
04-20 14:55:24.312: I/DEBUG(224):     #02  75ea4648  715ad788  [anon:libc_malloc]
04-20 14:55:24.312: I/DEBUG(224):          75ea464c  7754f91b  /data/app-lib/info.rborn.mst-2/libcom.pushwoosh.module.so (com::pushwoosh::module::PushnotificationsModule::getPushToken(v8::FunctionCallbackInfo<v8::Value> const&)+130)
DimanAM commented 7 years ago

Can you reproduce the issue on current Pushwoosh Sample? Could you also specify Android NDK version you are using?

it seems that the crash happens because on the second start the app tries to send success multiple times.

I was not able to reproduce this behaviour with multiple successful registration callbacks. Also changing PushnotificationsModule.checkMessage() to invoke successCallback multiple times does not make this issue appear. So I do not think it is directly connected to this problem.

As I see from stacktrace, this issue occurs in native bindings for getPushToken. Please check if the problem persists after removing all usages of this method.

rborn commented 7 years ago

Hi, thank you for your fast reply.

Any idea? Thank you!

rborn commented 7 years ago

I can reproduce the issue with the sample app by adding the next code in alloy.js

var pushwoosh = require('com.pushwoosh.module');
pushwoosh.getNotificationSettings();
pushwoosh.getPushToken();
DimanAM commented 7 years ago

Putting this code in alloy.js does indeed reproduce the problem. I suppose it is connected to Titanium initialization process. It is simply not ready to execute module methods at this point after restart (I wonder why).

As a workaround you cat put this code in index.js or wrap it with setTimeout:

setTimeout(function() {
    var pushwoosh = require('com.pushwoosh.module');
    pushwoosh.getPushToken();
    pushwoosh.getNotificationSettings();
}, 0);

Modifying kroll java method in pushwoosh module does not change anything because execution does not even reach this point. It crashes in native bindings that are automatically generated by Ti build system (android/build/generated/jni/com.pushwoosh.module.PushnotificationsModule.cpp).

rborn commented 7 years ago

Ok, I will try and let you know. Thank you.

rborn commented 7 years ago

Ok, moving away from alloy the pushwoosh code seems to fix the crash. Now to adjust the logic to do what was doing before 😟

Thank you, I'll close the ticket.