Search Unity

Question Android crash when VideoPlayer. stop() is executed

Discussion in 'Audio & Video' started by bx3776, Nov 16, 2022.

  1. bx3776

    bx3776

    Joined:
    Nov 25, 2014
    Posts:
    13
    I created a simple android video player application in unity2021.3.12. It played in URL mode. At first, everything was normal. But whenever I executed VideoPlayer When Stop(), the application always crashes, and the exception capture cannot catch stop(). However, if I use Unity2020.3.4 to export and run again, everything is normal and stop () performs well. What is the reason for this, or what needs to be done to stop normally when I use 2021.3.12?
     
    kazak_tm likes this.
  2. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Can you check the logcat to see if you get an error?
     
  3. bx3776

    bx3776

    Joined:
    Nov 25, 2014
    Posts:
    13
    This is Log in Android Studio when Crashes

    Code (CSharp):
    1. 15:39:50.814  E  FATAL EXCEPTION: UnityMain
    2.                  Process: com.DefaultCompany.NewUnityProject, PID: 22291
    3.                  java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    4.                  Version '2021.3.12f1c2 (ffeb050254a0)', Build type 'Development', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
    5.                  Build fingerprint: 'HUAWEI/NOH-AN00/HWNOH:10/HUAWEINOH-AN00/102.0.0.280C00:user/release-keys'
    6.                  Revision: '0'
    7.                  ABI: 'arm64'
    8.                  Timestamp: 2022-11-15 15:39:49+0800
    9.                  pid: 22291, tid: 23578, name: Background Job.  >>> com.DefaultCompany.NewUnityProject <<<
    10.                  uid: 10745
    11.                  signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    12.                  Cause: null pointer dereference
    13.                      x0  0000000000000000  x1  00000000000035e6  x2  0000000070cf5c00  x3  0000000000000002
    14.                      x4  0000006fc03168f0  x5  0000006fc0316878  x6  0000000000000000  x7  002e00640069006f
    15.                      x8  ffffff80ffffffd8  x9  0000006fc0316720  x10 0000006fc0316750  x11 6975e3601bdf8c4d
    16.                      x12 0000006fc03167c0  x13 0069007400630065  x14 0000000000000000  x15 0000000000000000
    17.                      x16 00000070d96e8240  x17 00000070dbc27d60  x18 0000006ec89e0000  x19 0000006fc0317020
    18.                      x20 0000006fc0316878  x21 0000006fc03168f0  x22 000000704618e0a0  x23 0000000000000002
    19.                      x24 0000000000000000  x25 00000070d812ff10  x26 0000000000000000  x27 0000006e559ffa00
    20.                      x28 0000006fc0317020  x29 0000006fc03167b0
    21.                      sp  0000006fc0316690  lr  00000070d96048ac  pc  00000070d9580030
    22.                
    23.                  backtrace:
    24.                        #00 pc 0000000000116030  /system/lib64/libandroid_runtime.so (BuildId: e99b2e2e44982c12a4dc2e20fbdbab43)
    25.                        #01 pc 000000000019a8a8  /system/lib64/libandroid_runtime.so (BuildId: e99b2e2e44982c12a4dc2e20fbdbab43)
    26.                        #02 pc 00000000000587a8  /system/lib64/libbinder.so (android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+136) (BuildId: 5a8d1089356748819d9494d2f5f1a6bc)
    27.                        #03 pc 000000000004c248  /system/lib64/libmedia.so (BuildId: a5fb2fe9293e08ae66f184e85492ba2b)
    28.                        #04 pc 000000000015386c  /system/lib64/libstagefright.so (android::ClearMediaHTTP::disconnect()+120) (BuildId: 5a4b48048e1e8b9b7353781c2d32daf0)
    29.                        #05 pc 000000000015a8f4  /system/lib64/libstagefright.so (android::NuMediaExtractor::~NuMediaExtractor()+560) (BuildId: 5a4b48048e1e8b9b7353781c2d32daf0)
    30.                        #06 pc 000000000015aa84  /system/lib64/libstagefright.so (android::NuMediaExtractor::~NuMediaExtractor()+16) (BuildId: 5a4b48048e1e8b9b7353781c2d32daf0)
    31.                        #07 pc 000000000000f6e0  /system/lib64/libutils.so (android::RefBase::decStrong(void const*) const+112) (BuildId: d5e46e511fe7f84584dfbf4942e8ac28)
    32.                        #08 pc 000000000001ca3c  /system/lib64/libmediandk.so (BuildId: 0d818036e6ffc84aebc9fc15b84ac170)
    33.                        #09 pc 0000000000683d8c  /data/app/com.DefaultCompany.NewUnityProject-CF2a5wKHwMyAFz_Je-BoNw==/lib/arm64/libunity.so (AndroidVideoMedia<AndroidMediaNDK::Traits>::ThreadedCleanup()+76) (BuildId: 8a868e4da224b6ab33c604054b12818128870df5)
    34.                        #10 pc 0000000000630370  /data/app/com.DefaultCompany.NewUnityProject-CF2a5wKHwMyAFz_Je-BoNw==/lib/arm64/libunity.so (BuildId: 8a868e4da224b6ab33c604054b12818128870df5)
    35.                        #11 pc 000000000025a550  /data/app/com.DefaultCompany.NewUnityProject-CF2a5wKHwMyAFz_Je-BoNw==/lib/arm64/libunity.so (JobQueue::Exec(JobInfo*, long long, int, bool)+104) (BuildId: 8a868e4da224b6ab33c604054b12818128870df5)
    36.                        #12 pc 000000000025a880  /data/app/com.DefaultCompany.NewUnityProject-CF2a5wKHwMyAFz_Je-BoNw==/lib/arm64/libunity.so (JobQueue::ExecuteJobFromHighPriorityStack(bool)+64) (BuildId: 8a868e4da224b6ab33c604054b12818128870df5)
    37.                        #13 pc 000000000025aabc  /data/app/com.DefaultCompany.NewUnityProject-CF2a5wKHwMyAFz_Je-BoNw==/lib/arm64/libunity.so (JobQueue::ProcessJobs(JobQueue::ThreadInfo*, void*)+244) (BuildId: 8a868e4da224b6ab33c604054b12818128870df5)
    38.                        #14 pc 0000000000259ef4  /data/app/com.DefaultCompany.NewUnityProject-CF2a5wKHwMyAFz_Je-BoNw==/lib/arm64/libunity.so (JobQueue::WorkLoop(void*)+264) (BuildId: 8a868e4da224b6ab33c604054b12818128870df5)
    39. 15:39:50.815  E        #15 pc 000000000037e018  /data/app/com.DefaultCompany.NewUnityProject-CF2a5wKHwMyAFz_Je-BoNw==/lib/arm64/libunity.so (Thread::RunThreadWrapper(void*)+796) (BuildId: 8a868e4da224b6ab33c604054b12818128870df5)
    40.                        #16 pc 00000000000cf7c0  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: b91c775ccc9b0556e91bc575a2511cd0)
    41.                        #17 pc 00000000000721a8  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: b91c775ccc9b0556e91bc575a2511cd0)
    42.                
    43.                      at libandroid_runtime.0x116030(Native Method)
    44.                      at libandroid_runtime.0x19a8a8(Native Method)
    45.                      at libbinder.android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)(transact:136)
    46.                      at libmedia.0x4c248(Native Method)
    47.                      at libstagefright.android::ClearMediaHTTP::disconnect()(disconnect:120)
    48.                      at libstagefright.android::NuMediaExtractor::~NuMediaExtractor()(~NuMediaExtractor:560)
    49.                      at libstagefright.android::NuMediaExtractor::~NuMediaExtractor()(~NuMediaExtractor:16)
    50.                      at libutils.android::RefBase::decStrong(void const*) const(decStrong:112)
    51.                      at libmediandk.0x1ca3c(Native Method)
    52.                      at libunity.AndroidVideoMedia<AndroidMediaNDK::Traits>::ThreadedCleanup()(ThreadedCleanup:76)
    53.                      at libunity.0x630370(Native Method)
    54.                      at libunity.JobQueue::Exec(JobInfo*, long long, int, bool)(Exec:104)
    55.                      at libunity.JobQueue::ExecuteJobFromHighPriorityStack(bool)(ExecuteJobFromHighPriorityStack:64)
    56.                      at libunity.JobQueue::ProcessJobs(JobQueue::ThreadInfo*, void*)(ProcessJobs:244)
    57.                      at libunity.JobQueue::WorkLoop(void*)(WorkLoop:264)
    58.                      at libunity.Thread::RunThreadWrapper(void*)(RunThreadWrapper:796)
    59.                      at libc.__pthread_start(void*)(__pthread_start:36)
    60.                      at libc.__start_thread(__start_thread:64)
     
  4. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Can you tell me your android API version? Is your phone using API 31 or 32? In any case, it is a crash in Unity, so I would open a bug report so we can investigate. Make sure you provide the logcat with it. After opening it, paste the ticket number here so I help the QA a little bit.
     
  5. flintcheeze

    flintcheeze

    Joined:
    Sep 10, 2015
    Posts:
    80
    Just upgrade your Unity to 2022.1.23f1
    Unity 2021 series has that bug that’s crashes apk on start or in between functions… Save yourself the stress
     
    The_Island likes this.
  6. World_Familiar

    World_Familiar

    Joined:
    Jul 3, 2017
    Posts:
    2
    Any other progress?
    Has it been fixed?
     
  7. World_Familiar

    World_Familiar

    Joined:
    Jul 3, 2017
    Posts:
    2
    I also encountered the same bug , my phone's android is using API 31 .
     
  8. flintcheeze

    flintcheeze

    Joined:
    Sep 10, 2015
    Posts:
    80
    Apk crash on start fix!
    Delete all android resolved library
    It will work
    But I highly recommend you should delete the libraries little by little till you have a playable apk
    The crash is as a result of duplicate aar and plugins which Unity ignores on build
     
  9. ThisIsDangerous

    ThisIsDangerous

    Joined:
    Dec 3, 2018
    Posts:
    39
    2021.3.13f1 crashes on videoPlayer.Stop() in Android too. Will upgrade to the latest LTS in hopes the bug is fixed there. Will report back here.
     
  10. ThisIsDangerous

    ThisIsDangerous

    Joined:
    Dec 3, 2018
    Posts:
    39
    Nope, 2021.3.16f1 (current LTS) still has the bug. A shame.
     
    rulu420 likes this.
  11. kazak_tm

    kazak_tm

    Joined:
    Sep 7, 2021
    Posts:
    12
  12. kazak_tm

    kazak_tm

    Joined:
    Sep 7, 2021
    Posts:
    12
    In my test project I use only XR Interaction Toolkit, XR Plugin Manager and Open XR. Crashes start after installing these plugins.
     
  13. rulu420

    rulu420

    Joined:
    Apr 15, 2013
    Posts:
    2
    Android crash when VideoPlayer. stop() is executed . I am also facing the same issue in 2021.3.16f1. This doesn't happen in Editor but on Android it does.

    Minimum API level 24

    Target API Level 29/31

    Tried Unity 2022.2.0f1 : It didn't crash for a couple of builds but then all builds started crashing on VideoPlayer.stop()
     
    Last edited: Dec 29, 2022
  14. ehudcandivore

    ehudcandivore

    Joined:
    Jul 18, 2018
    Posts:
    12
    Happens to me as well... Is there a workaround? Video playback is simply broken on the 2021.3 LTS release?
     
  15. KinuxUnity

    KinuxUnity

    Joined:
    Dec 4, 2015
    Posts:
    8
    same bug , same stack trace on android emulator
     
  16. N7Nico

    N7Nico

    Joined:
    Sep 1, 2017
    Posts:
    3
    Same bug and problem for me too... :/
     
  17. kazak_tm

    kazak_tm

    Joined:
    Sep 7, 2021
    Posts:
    12
    Response from the Unity QA team: "We actually know about this issue and you can check the status here: https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-20661 There are fixes Under Consideration for 2021.3, 2022.2, 2023.1 Streams Please reach out to me if I can answer any questions or be of further help."
     
  18. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Yeah, sorry for the long delay in our response. Most people on the team came back last week. I just pushed the fix on 2023 that fix this issue https://issuetracker.unity3d.com/is...g-the-source-url-of-a-video-player-in-android. I am waiting for it to land in 2023. After that, it should get backported relatively quickly as it is a high priority.

    There is a lot of people here so I am not sure if you all have the same issue. Your log should look like @bx3776. If you have something else then it is maybe another bug. You can check with ADB, Android Log Cat package or Android Studio
     
    Last edited: Jan 17, 2023
  19. shochet

    shochet

    Joined:
    Dec 17, 2013
    Posts:
    30
    Crashing for me on Android after updating from 2020.3.32 to 2020.3.43, which I thought would be safe.
    Crash happens when calling player.Stop() on a VideoPlayer with a url source. Destroying the GameObject with the VideoPlayer also crashes. Pause() seems to behave but user cannot get past the video without crashing.

    Any known workarounds?
     
  20. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    The only thing you can do right now is to take a slightly older Unity version. You should be safe using an older version than 2022.1.21f1, 2021.3.12f1 and 2020.3.43f1. It is where the regression was introduced. So @shochet, I would downgrade to 2020.3.42f1 if you can.
     
    ibrahimxyz, cabanel and shochet like this.
  21. soundleaders

    soundleaders

    Joined:
    Jan 21, 2019
    Posts:
    1
    2021.3.16f1 is too, video player scene -> move other scene after crash or set video player Stop() (null pointer, android, !!! only url used !!!)
    [use macbook pro m1, ventura 13.0, unity 2021.3.16f1, il2cpp build, target api 33]
     
    Last edited: Jan 19, 2023
  22. shochet

    shochet

    Joined:
    Dec 17, 2013
    Posts:
    30
    Thanks for the note. Downgrading to 2020.3.42f1 indeed fixed the crash. Perhaps there should be a known issue listed for this in .43 release notes - would have saved some effort here.
     
  23. shochet

    shochet

    Joined:
    Dec 17, 2013
    Posts:
    30
    Update - while downgrading my test project fixed the crash, downgrading our actual production project created 999+ Package Manager errors every time the project loads or when hitting play.

    @The_Island have you ever seen this before? I've never downgraded Unity versions before. Already tried deleting the project Library folder and reimporting - did not help. I'm not finding much help for these errors elsewhere in the forums. Any ideas would be appreciated. The .md and .cs files sure look ok to me on disk though they are not XML files.

    upload_2023-1-19_16-32-5.png
     
  24. Grinchi

    Grinchi

    Joined:
    Apr 19, 2014
    Posts:
    130
    Lost whole day on this one :D thought it was my problem with video steaming :D
     
  25. AndyFire3

    AndyFire3

    Joined:
    Mar 11, 2018
    Posts:
    1
    It is still crashing in 2022.2.5 but I found a workaround which is to pause the video and give some time before calling Stop(). It is not great but it unblocked me for now until this is fix in 2022 version (ref: bug).

    Code (CSharp):
    1.        
    2.         public void Stop()
    3.         {
    4.             Timing.RunCoroutine(StopRoutine());
    5.         }
    6.         private IEnumerator<float> StopRoutine()
    7.         {
    8.             _videoPlayer.Pause();
    9.             _videoPlayer.frame = 0;
    10.             _videoPlayer.url = "";
    11.             yield return Timing.WaitForSeconds(1f);
    12.             _videoPlayer.Stop();
    13.         }
    14.  
    15.  
     
  26. hubin-hj

    hubin-hj

    Joined:
    Mar 17, 2020
    Posts:
    1
    this workaround does not work in 2021.3.17
     
  27. Oyshoboy

    Oyshoboy

    Joined:
    Jan 6, 2017
    Posts:
    20
    Problem still on unity version 2021.3.18f1
     
  28. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Last edited: Feb 17, 2023
    Oyshoboy likes this.
  29. ZoroMC

    ZoroMC

    Joined:
    Jul 22, 2014
    Posts:
    4
    Is this issue fixed in 2022.2.7f1? We are currently getting the same crash
     
  30. ZoroMC

    ZoroMC

    Joined:
    Jul 22, 2014
    Posts:
    4
    @The_Island This issue is affecting 2022.2.7f1 and 2022.2.9f1 also. When could we expect a fix? Thanks
     
  31. rusi

    rusi

    Joined:
    Jun 15, 2015
    Posts:
    1
    @The_Island we also still see the bug on 2021.3.19f1 which is supposed to include a fix.
     
  32. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    ZoroMC likes this.
  33. ThisIsDangerous

    ThisIsDangerous

    Joined:
    Dec 3, 2018
    Posts:
    39
    Is there an ETA of when 2021.3.21f1 is going to be available for download?
     
  34. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    It came out today with 2022.2.11f1
     
  35. bellshine

    bellshine

    Joined:
    May 26, 2022
    Posts:
    2
    same error in 2021.3.15f1
     
  36. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    The fix landed in 2021.3.21f1
     
    RafaelGomes00 likes this.
  37. bellshine

    bellshine

    Joined:
    May 26, 2022
    Posts:
    2
    Thanks for the info. I want people with 2021.3.15 to know about this issue.
     
  38. carlsonkenson

    carlsonkenson

    Joined:
    May 7, 2021
    Posts:
    4
    I'm not sure that's a safe workaround. I am on Unity 2019.4.40 and facing the exact same issue.
     
  39. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    I double-checked and you are right. It was backported to 2019.4.38f1. Unfortunately, the fix will not be backported to 2019.4. You have to either upgrade or downgrade to 2019.4.37f1
     
  40. carlsonkenson

    carlsonkenson

    Joined:
    May 7, 2021
    Posts:
    4
    Alright, I see. I found a workaround though. I created a Coroutine instead of stopping the video immediately. In the Coroutine, I pause the video first, for a few seconds, then yield return waitfor....for a less than a second, before Stopping the video. This Stopped the crashing, on Android.

    What about iap for Android? Is IAP definitely unsupported for older versions of Unity (last time I checked, trying to import the IAP package (the minimum version supported for the Google Play Store) in a version of Unity older than 2020 results the project breaking completely. Any fixes for those of us on older versions of Unity?