Pushwoosh / pushwoosh-appcelerator-titanium

Other
33 stars 16 forks source link

Error when receiving Push in Android #19

Closed carliskisantiago closed 7 years ago

carliskisantiago commented 8 years ago

Hello, I'm developing an app using Pushwoosh but now i'm facing an error with Android (iOS works fine). Sometimes when I receive a push using the remote API my app crashes and I get this error log (I'm attaching the complete error log) log.txt . I'm using Titanium SDK 4.1.0. Thanks in advance. Santiago.

[ERROR] : JNIUtil: ProxyFactory: failed to find class for ti.modules.titanium.network.HTTPClientProxy [ERROR] : ProxyFactory: No proxy info found for class. [INFO] : I/System.out: TiHttpClient-54 calls detatch() [INFO] : art: sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: obj == null [INFO] : art: sart/runtime/check_jni.cc:65] in call to CallVoidMethodA [INFO] : art: sart/runtime/check_jni.cc:65] from java.lang.Object org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(long, long, java.lang.Object[]) [INFO] : art: sart/runtime/check_jni.cc:65] "KrollRuntimeThread" prio=5 tid=10 Runnable [INFO] : art: sart/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x32c07380 self=0xb4d10000 [INFO] : art: sart/runtime/check_jni.cc:65] | sysTid=26332 nice=0 cgrp=apps sched=0/0 handle=0xafc05e00 [INFO] : art: sart/runtime/check_jni.cc:65] | state=R schedstat=( 7990924900 650400692 2930 ) utm=722 stm=76 core=3 HZ=100 [INFO] : art: sart/runtime/check_jni.cc:65] | stack=0xb3813000-0xb3815000 stackSize=1052KB [INFO] : art: sart/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held) [INFO] : art: sart/runtime/check_jni.cc:65] native: #00 pc 00004c58 /system/lib/libbacktracelibc++.so (UnwindCurrent::Unwind(unsigned int, ucontext)+23) [INFO] : art: sart/runtime/check_jni.cc:65] native: #01 pc 000034c1 /system/lib/libbacktracelibc++.so (Backtrace::Unwind(unsigned int, ucontext)+8) [INFO] : art: sart/runtime/check_jni.cc:65] native: #02 pc 0025b3d5 /system/lib/libart.so (art::DumpNativeStack(std::1::basic_ostream<char, std::__1::chartraits >&, int, char const, art::mirror::ArtMeth [INFO] : art: sart/runtime/check_jni.cc:65] native: #03 pc 0023e673 /system/lib/libart.so (art::Thread::Dump(std::1::basic_ostream<char, std::__1::char_traits >&) const+162) [INFO] : art: sart/runtime/checkjni.cc:65] native: #04 pc 000b32ad /system/lib/libart.so (art::JniAbort(char const, char const_)+620) [INFO] : art: sart/runtime/check_jni.cc:65] native: #05 pc 000b39dd /system/lib/libart.so (art::JniAbortF(char const, char const, ...)+68) [INFO] : art: sart/runtime/check_jni.cc:65] native: #06 pc 001b8a43 /system/lib/libart.so (art::JNI::CallVoidMethodA(_JNIEnv, _jobject, jmethodID, jvalue*)+614)

shaders commented 8 years ago

Could you please make sure you are calling push callbacks on a main thread?

Try to wrap them in setTimeout as outlined here: http://docs.pushwoosh.com/docs/appcelerator-titanium

pushnotifications.pushNotificationsRegister({
    "pw_appid": "ENTER_PUSHWOOSH_APPID_HERE",
    success:function(e)
    {
        setTimeout(function() {
            Ti.API.info('JS registration success event: ' + e.registrationId);
        }, 0);
    },
    error:function(e)
    {
        setTimeout(function() {
            Ti.API.error("Error during registration: "+e.error);
        }, 0);
    },
    callback:function(e) // called when a push notification is received
    {
        setTimeout(function() {
            //push notifications title: e.data.aps.alert
            Ti.API.info('JS message event: ' + JSON.stringify(e.data));
        }, 0);
    }
});
carliskisantiago commented 8 years ago

Yes we're calling push callbacks on the main thread and we set the timeouts as you mention. BTW, we are using 2000 ms insted of 0 because that causes more failures. Everything is working OK but sometimes it fails and only using Android, not iOS. We don't know what we can modify to get it working.

shaders commented 8 years ago

Hi,

I've got the response from the Titanium team. It looks like you have to update to the 5.2.x version of Titanium. Appcelerator made a change that I think was the ultimate resolution to the problem. The 4.x line was pretty buggy overall.

Specifically, they now check for null here: https://github.com/appcelerator/titanium_mobile/blob/384775e13e153620194c874699490fe9524ce9d9/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L1214

carliskisantiago commented 8 years ago

@shaders thanks for your response, we made that change and we switched to Titanium SDK 5.2.0 but now we are getting a similiar error from other Proxy. I'm attaching the error log again. Every tip will be useful as we're soon to reach launch date. Thanks again :D log.txt