yasirkula / UnityNativeShare

A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS
MIT License
891 stars 131 forks source link

[Solved] Crash and freeze app Android - text share #46

Closed DungDajHjep closed 4 years ago

DungDajHjep commented 4 years ago

Unity 2018.4.4 Build gradle. Crash or freeze on android app

log: Crash device: 07-24 18:27:21.785 1284-6640/? E/Watchdog: !@Sync 4129 [2019-07-24 11:27:21.785] FD count : 535 07-24 18:27:23.221 750-880/? E/Netd: getNetworkForDns: getNetId from enterpriseCtrl is netid 0 07-24 18:27:24.823 7030-7858/? A/.space.shooter: indirect_reference_table.cc:61] JNI ERROR (app bug): accessed stale Local 0x1 (index 0 in a table of size 0) 07-24 18:27:24.844 7030-7209/? E/AndroidRuntime: FATAL EXCEPTION: UnityChoreographer Process: com.game.space.shooter2, PID: 7030 java.lang.IllegalArgumentException: callback must not be null at android.view.Choreographer.postFrameCallbackDelayed(Choreographer.java:511) at android.view.Choreographer.postFrameCallback(Choreographer.java:494) at bitter.jnibridge.JNIBridge.invoke(Native Method) at bitter.jnibridge.JNIBridge$a.invoke(Unknown Source:20) at java.lang.reflect.Proxy.invoke(Proxy.java:1006) at $Proxy8.doFrame(Unknown Source) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:947) at android.view.Choreographer.doCallbacks(Choreographer.java:761) at android.view.Choreographer.doFrame(Choreographer.java:693) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:65) 07-24 18:27:25.181 7881-7881/? E/Zygote: isWhitelistProcess - Process is Whitelisted

=================================================================

=================================================================

Freeze device: 07-24 18:25:59.242 719-719/? E/wificond: Failed to get NL80211_RATE_INFO_NOISE Failed to get NL80211_RATE_INFO_SNR Failed to get NL80211_STA_INFO_CNAHLOAD 07-24 18:25:59.242 1182-1335/? E/WificondControl: Noise: 0, Snr: -1, Chload: -1 07-24 18:25:59.353 1182-1322/? E/libfingersense_wrapper: libfingersense.so was not loaded 07-24 18:25:59.422 1182-1322/? E/libfingersense_wrapper: libfingersense.so was not loaded 07-24 18:26:00.055 13786-13786/? E/DateView: DateView,mCurrentTime: 1563967560055 07-24 18:26:00.083 13786-13786/? E/DateLunarView: mDateString is: Wed, 24 Jul mDateString is: Wed, 24 Jul 07-24 18:26:00.489 1182-1322/? E/libfingersense_wrapper: libfingersense.so was not loaded 07-24 18:26:00.581 1182-1322/? E/libfingersense_wrapper: libfingersense.so was not loaded 07-24 18:26:01.263 13285-13644/? A/zygote: indirect_reference_table.cc:75] JNI ERROR (app bug): accessed stale Local 0x9 (index 0 in a table of size 0) 07-24 18:26:01.938 13285-13644/? A/zygote: runtime.cc:495] Runtime aborting... runtime.cc:495] Aborting thread: runtime.cc:495] "Thread-140" prio=5 tid=32 Runnable runtime.cc:495] | group="" sCount=0 dsCount=0 flags=0 obj=0x12e00000 self=0xb49a5e00 runtime.cc:495] | sysTid=13644 nice=0 cgrp=default sched=0/0 handle=0xb369e970 runtime.cc:495] | state=R schedstat=( 942189 756251 12 ) utm=0 stm=0 core=4 HZ=100 runtime.cc:495] | stack=0xb35a4000-0xb35a6000 stackSize=1006KB runtime.cc:495] | held mutexes= "abort lock" "mutator lock"(shared held) runtime.cc:495] native: #00 pc 002c6aa3 /system/lib/libart.so (_ZN3art15DumpNativeStackERNSt3113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+130) runtime.cc:495] native: #01 pc 00359273 /system/lib/libart.so (_ZNK3art6Thread9DumpStackERNSt3113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMapb+202) runtime.cc:495] native: #02 pc 00355757 /system/lib/libart.so (_ZNK3art6Thread4DumpERNSt3113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMapb+34) runtime.cc:495] native: #03 pc 00346015 /system/lib/libart.so (_ZNK3art10AbortState10DumpThreadERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEPNS_6ThreadE+28) runtime.cc:495] native: #04 pc 00345df7 /system/lib/libart.so (_ZNK3art10AbortState4DumpERNSt3113basic_ostreamIcNS1_11char_traitsIcEEEE+346) runtime.cc:495] native: #05 pc 0033a7b7 /system/lib/libart.so (_ZN3art7Runtime5AbortEPKc+110) runtime.cc:495] native: #06 pc 0033aeb3 /system/lib/libart.so (_ZN3art7Runtime7AborterEPKc+10) runtime.cc:495] native: #07 pc 003f3419 /system/lib/libart.so (_ZN7android4base10LogMessageD1Ev+456) runtime.cc:495] native: #08 pc 001c8283 /system/lib/libart.so (_ZN3art22IndirectReferenceTable17AbortIfNoCheckJNIERKNSt3112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE+166) runtime.cc:495] native: #09 pc 00234e5f /system/lib/libart.so (_ZNK3art22IndirectReferenceTable10GetCheckedEPv+266) runtime.cc:495] native: #10 pc 0035d6a1 /system/lib/libart.so (_ZNK3art6Thread13DecodeJObjectEP8_jobject+48) runtime.cc:495] native: #11 pc 003358af /system/lib/libart.so (_ZN3art8ArgArray24BuildArgArrayFromJValuesERKNS_33ScopedObjectAccessAlreadyRunnableENS_6ObjPtrINS_6mirror6ObjectEEEP6jvalue+150) runtime.cc:495] native: #12 pc 00335719 /system/lib/libart.so (_ZN3art17InvokeWithJValuesERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDP6jvalue+280) runtime.cc:495] native: #13 pc 0027e089 /system/lib/libart.so (_ZN3art3JNI23CallStaticObjectMethodAEP7_JNIEnvP7_jclassP10_jmethodIDP6jvalue+432) runtime.cc:495] native: #14 pc 002ff7f0 /data/app/com.game.space.shooter2-o0x4Hz5SzpB-R-_tpGIzfQ==/lib/arm/libunity.so -R-_tpGIzfQ==/lib/arm/libil2cpp.so (???) runtime.cc:495] native: #36 pc 00617f94 /data/app/com.game.space.shooter2-o0x4Hz5SzpB-R-_tpGIzfQ==/lib/arm/libil2cpp.so (???)4Hz5SzpB-R-_tpGIzfQ==/lib/arm/libil2cpp.so (???) runtime.cc:495] native: #40 pc 000486cf /system/lib/libc.so (_ZL15pthread_startPv+22) runtime.cc:495] native: #41 pc 0001b02f /system/lib/libc.so (start_thread+32) runtime.cc:495] (no managed stack frames) runtime.cc:495] runtime.cc:495] "main" prio=5 tid=1 Native runtime.cc:495] | group="" sCount=1 dsCount=0 flags=1 obj=0x731614e8 self=0xee5cc000 runtime.cc:495] | sysTid=13285 nice=-10 cgrp=default sched=0/0 handle=0xf28c34a8 runtime.cc:495] | state=S schedstat=( 2298179179 103258336 4336 ) utm=168 stm=61 core=0 HZ=100 runtime.cc:495] | stack=0xff6da000-0xff6dc000 stackSize=8MB runtime.cc:495] | held mutexes= runtime.cc:495] kernel: (couldn't read /proc/self/task/13285/stack) runtime.cc:495] native: #00 pc 00049cf4 /system/lib/libc.so (epoll_pwait+20) runtime.cc:495] native: #01 pc 0001b441 /system/lib/libc.so (epoll_pwait+60) runtime.cc:495] native: #02 pc 0001b471 /system/lib/libc.so (epoll_wait+12) runtime.cc:495] native: #03 pc 0001041b /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+118) runtime.cc:495] native: #04 pc 0001030d /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+32) runtime.cc:495] native: #05 pc 000bdf19 /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+24) runtime.cc:495] native: #06 pc 001ba3bd /system/framework/arm/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnceJI+92) runtime.cc:495] at android.os.MessageQueue.nativePollOnce(Native method) runtime.cc:495] at android.os.MessageQueue.next(MessageQueue.java:379) runtime.cc:495] at android.os.Looper.loop(Looper.java:144) runtime.cc:495] at android.app.ActivityThread.main(ActivityThread.java:7425) runtime.cc:495] at java.lang.reflect.Method.invoke(Native method) runtime.cc:495] at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) runtime.cc:495] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) runtime.cc:495] runtime.cc:495] "Jit thread pool worker thread 0" prio=5 tid=2 Native runtime.cc:495] | group="" sCount=1 dsCount=0 flags=1 obj=0x15400250 self=0xde298200 runtime.cc:495] | sysTid=13290 nice=9 cgrp=default sched=0/0 handle=0xe20d6970 runtime.cc:495] | state=S schedstat=( 255493239 123402082 410 ) utm=17 stm=8 core=3 HZ=100 runtime.cc:495] | stack=0xe1fd8000-0xe1fda000 stackSize=1022KB runtime.cc:495] | held mutexes= runtime.cc:495] kernel: (couldn't read /proc/self/task/13290/stack) runtime.cc:495] native: #00 pc 00018e54 /system/lib/libc.so (syscall+28) runtime.cc:495] native: #01 pc 000b3c4d /system/lib/libart.so (_ZN3art17ConditionVariable16WaitHoldingLocksEPNS_6ThreadE+88) runtime.cc:495] native: #02 pc 0036ea4d /system/lib/libart.so (_ZN3art10ThreadPool7GetTaskEPNS_6ThreadE+172) runtime.cc:495] native: #03 pc 0036e2eb /system/lib/libart.so (_ZN3art16ThreadPoolWorker3RunEv+62) runtime.cc:495] native: #04 pc 0036def9 /system/lib/libart.so (_ZN3art16ThreadPoolWorker8CallbackEPv+92) runtime.cc:495] native: #05 pc 000486cf /system/lib/libc.so (_ZL15pthread_startPv+22) runtime.cc:495] native: #06 pc 0001b02f /system/lib/libc.so (start_thread+32) runtime.cc:495] (no managed stack frames) runtime.cc:495] runtime.cc:495] "Signal Catcher" prio=5 tid=3 WaitingInMainSignalCatcherLoop runtime.cc:495] | group="" sCount=1 dsCount=0 flags=1 obj=0x154003d8 self=0xee5ccc00 07-24 18:26:01.940 13285-13644/? A/zygote: runtime.cc:495] | sysTid=13291 nice=0 cgrp=default sched=0/0 handle=0xe0649970 runtime.cc:495] | state=S schedstat=( 470832 27604 2 ) utm=0 stm=0 core=0 HZ=100 runtime.cc:495] | stack=0xe054f000-0xe0551000 stackSize=1006KB runtime.cc:495] | held mutexes= runtime.cc:495] kernel: (couldn't read /proc/self/task/13291/stack) runtime.cc:495] native: #00 pc 0004a024 /system/lib/libc.so (__rt_sigtimedwait+12) runtime.cc:495] native: #01 pc 000216cf /system/lib/libc.so (sigwait+70) runtime.cc:495] native: #02 pc 0034b00b /system/lib/libart.so (_ZN3art9SignalSet4WaitEv+22) runtime.cc:495] native: #03 pc 0034ac17 /system/lib/libart.so (_ZN3art13SignalCatcher13WaitForSignalEPNS_6ThreadERNS_9SignalSetE+186) runtime.cc:495] native: #04 pc 00349aff /system/lib/libart.so (_ZN3art13SignalCatcher3RunEPv+182) runtime.cc:495] native: #05 pc 000486cf /system/lib/libc.so (_ZL15pthread_startPv+22) runtime.cc:495] native: #06 pc 0001b02f /system/lib/libc.so (start_thread+32) runtime.cc:495] (no managed stack frames) runtime.cc:495] runtime.cc:495] "ReferenceQueueDaemon" prio=5 tid=4 Waiting runtime.cc:495] | group="" sCount=1 dsCount=0 flags=1 obj=0x154004f0 self=0xee5cde00 runtime.cc:495] | sysTid=13292 nice=4 cgrp=default sched=0/0 handle=0xccfed970 runtime.cc:495] | state=S schedstat=( 18838541 1083333 27 ) utm=1 stm=0 core=1 HZ=100 runtime.cc:495] | stack=0xcceeb000-0xcceed000 stackSize=1038KB runtime.cc:495] | held mutexes= runtime.cc:495] kernel: (couldn't read /proc/self/task/13292/stack) runtime.cc:495] native: #00 pc 00018e54 /system/lib/libc.so (syscall+28) runtime.cc:495] native: #01 pc 000b3c4d /system/lib/libart.so (_ZN3art17ConditionVariable16WaitHoldingLocksEPNS_6ThreadE+88) runtime.cc:495] native: #02 pc 002c201f /system/lib/libart.so (_ZN3art7Monitor4WaitEPNS_6ThreadExibNS_11ThreadStateE+526) runtime.cc:495] native: #03 pc 002c35eb /system/lib/libart.so (_ZN3art7Monitor4WaitEPNS_6ThreadEPNS_6mirror6ObjectExibNS_11ThreadStateE+130) runtime.cc:495] native: #04 pc 002d4c6b /system/lib/libart.so (_ZN3artL11Object_waitEP7_JNIEnvP8_jobject+32) runtime.cc:495] native: #05 pc 00000583 /system/framework/arm/boot.oat (Java_java_lang_Object_wait+74) runtime.cc:495] at java.lang.Object.wait(Native method) runtime.cc:495] - waiting on <0x0ac2a2a6> (a java.lang.Class) runtime.cc:495] at java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:178) runtime.cc:495] - locked <0x0ac2a2a6> (a java.lang.Class) runtime.cc:495] at java.lang.Daemons$Daemon.run(Daemons.java:103) runtime.cc:495] at java.lang.Thread.run(Thread.java:784) runtime.cc:495] runtime.cc:495] "FinalizerDaemon" prio=5 tid=5 Waiting runtime.cc:495] | group="" sCount=1 dsCount=0 flags=1 obj=0x15400838 self=0xe1e0c600 runtime.cc:495] | sysTid=13293 nice=4 cgrp=default sched=0/0 handle=0xccee8970 runtime.cc:495] | state=S schedstat=( 35532295 2666666 44 ) utm=3 stm=0 core=2 HZ=100 runtime.cc:495] | stack=0xccde6000-0xccde8000 stackSize=1038KB runtime.cc:495] | held mutexes= runtime.cc:495] kernel: (couldn't read /proc/self/task/13293/stack) runtime.cc:495] native: #00 pc 00018e54 /system/lib/libc.so (syscall+28) runtime.cc:495] native: #01 pc 000b3c4d /system/lib/libart.so (_ZN3art17ConditionVariable16WaitHoldingLocksEPNS_6ThreadE+88) runtime.cc:495] native: #02 pc 002c201f /system/lib/libart.so (_ZN3art7Monitor4WaitEPNS_6ThreadExibNS_11ThreadStateE+526) runtime.cc:495] native: #03 pc 002c35eb /system/lib/libart.so (_ZN3art7Monitor4WaitEPNS_6ThreadEPNS_6mirror6ObjectExibNS_11ThreadStateE+130) runtime.cc:495] native: #04 pc 002d4c97 /system/lib/libart.so (_ZN3artL13Object_waitJIEP7_JNIEnvP8_jobjectxi+36) runtime.cc:495] native: #05 pc 0000089d /system/framework/arm/boot.oat (Java_java_lang_Object_wait__JI+92) runtime.cc:495] at java.lang.Object.wait(Native method) runtime.cc:495] - waiting on <0x04d204e7> (a java.lang.Object) runtime.cc:495] at java.lang.Object.wait(Object.java:422) runtime.cc:495] at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188) runtime.cc:495] - locked <0x04d204e7> (a java.lang.Object) runtime.cc:495] at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209) runtime.cc:495] at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:235) runtime.cc:495] at java.lang.Daemons$Daemon.run(Daemons.java:103) runtime.cc:495] at java.lang.Thread.run(Thread.java:784) runtime.cc:495] runtime.cc:495] "FinalizerWatchdogDaemon" prio=5 tid=6 Sleeping runtime.cc:495] | group="" sCount=1 dsCount=0 flags=1 obj=0x15400f80 self=0xe1e0cc00 runtime.cc:495] | sysTid=13294 nice=4 cgrp=default sched=0/0 handle=0xccde3970 runtime.cc:495] | state=S schedstat=( 501563 14583 10 ) utm=0 stm=0 core=2 HZ=100 runtime.cc:495] | stack=0xccce1000-0xccce3000 stackSize=1038KB runtime.cc:495] | held mutexes= runtime.cc:495] kernel: (couldn't read /proc/self/task/13294/stack) runtime.cc:495] native: #00 pc 00018e58 /system/lib/libc.so (syscall+32) runtime.cc:495] native: #01 pc 000b3f79 /system/lib/libart.so (_ZN3art17ConditionVariable9TimedWaitEPNS_6ThreadExi+108) runtime.cc:495] native: #02 pc 002c202f /system/lib/libart.so (_ZN3art7Monitor4WaitEPNS_6ThreadExibNS_11ThreadStateE+542) runtime.cc:495] native: #03 pc 002c35eb /system/lib/libart.so (_ZN3art7Monitor4WaitEPNS_6ThreadEPNS_6mirror6ObjectExibNS_11ThreadStateE+130)

yasirkula commented 4 years ago

Does setting Minify settings as None in Player Settings change anything? Do the same issues occur on a fresh new Unity project? If you have multiple Unity versions installed, can you also try the plugin on another Unity version to see if this is a bug in Unity? Do these issues occur after calling the Share function?

DungDajHjep commented 4 years ago

I did as you sad and found error happened when call Native share in a Task. Call in main thread will fix it. Thanks !

Code error example:

public void ShareA()
{
    if (dynamicLinkTask != null && dynamicLinkTask.IsCompleted == false) return;

    DynamicLinkComponents component = CreateDynamicLinkComponents();

    var options = new DynamicLinkOptions
    {
        PathLength = DynamicLinkPathLength.Unguessable
    };

    dynamicLinkTask =  DynamicLinks.GetShortLinkAsync(component, options).ContinueWith(task =>
    {
        if (task.IsCanceled)
        {
            Debug.LogError("GetShortLinkAsync was canceled.");
            return;
        }
        if (task.IsFaulted)
        {
            Debug.LogError("GetShortLinkAsync encountered an error: " + task.Exception);
            return;
        }

        // Short Link has been created.
        link = task.Result;
        Debug.LogFormat("Generated short link {0}", link.Url);
        //NativeShare.ShareMultiple("ABC ABCASD ASD ", null, link.Url.AbsoluteUri, "Title Subject");
        new NativeShare().SetSubject("lb_spaceshooter_pvp").SetText(string.Format("lb_challenge_message_{0}", link.Url.AbsoluteUri)).SetTitle("lb_pvp_title").Share();
        foreach (var item in link.Warnings)
        {
            Debug.Log(item);
        }

        dynamicLinkTask = null;
    });
}
yasirkula commented 4 years ago

Glad the issue is resolved, thanks for sharing your findings!

Kavita315 commented 2 years ago

I also have same problem app freezing when share text call

Screenshot 2021-09-02 at 11 54 16 AM

here is my code public void ShortLink(DynamicLinkComponents components) { var options = new DynamicLinkOptions { PathLength = DynamicLinkPathLength.Unguessable };

    DynamicLinks.GetShortLinkAsync(components, options).ContinueWith((task) =>
    {
        if (task.IsCanceled)
        {
            Debug.LogError("GetShortLinkAsync was canceled.");
            return;
        }
        if (task.IsFaulted)
        {
            Debug.LogError(" GetShortLinkAsync encountered an error : " + task.Exception);
            return;
        }

        // Short Link has been created.
        var link = task.Result;
        Debug.Log(" @@@@@@@@@@@@@@_ Generated short link :" + link.Url);
        SendLink(link.Url.ToString());

        foreach (var item in link.Warnings)
        {
            Debug.Log(item);
        }
    });
}
public void SendLink(string Link)
{
    Debug.Log("@@@@@@@@@@@@@@_SendLink____!");
    //
    Debug.Log("@@@@@@@@@@@@@@_SendLink" + Link);
    new NativeShare().SetTitle("title").SetText(Link).Share();

}

Its working in vivo but 2 3 rd time it freez 
and in one plus phone its not working at all not even once app freez in first attempt only

alos check the attch file i dont have any menify checked
yasirkula commented 2 years ago

Can you run the example code as is and make sure it works?

Kavita315 commented 2 years ago

Can you run the example code as is and make sure it works? Thank You ! Its working now with setcallback

public void SendLink(string Link) { //Debug.Log("@@@@@@@@@@@@@@_SendLink" + Link); StartCoroutine(firebaseLoadImageAndShare(Link));

}

private IEnumerator firebaseLoadImageAndShare(string link)
{

    yield return null;

    new NativeShare().SetText(link).SetCallback((result, shareTarget) => Debug.Log("Share result: " + result + ", selected app: " + shareTarget))
        .Share();
}