Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Android crash when seting value in VideoPlayer.frame

Discussion in 'Audio & Video' started by KimZigbang, Oct 18, 2022.

  1. KimZigbang

    KimZigbang

    Joined:
    Apr 24, 2020
    Posts:
    9
    I'm making a VideoPlayer UI that plays a video by streaming.
    When setting the value in UnityEngine.VideoPlayer.frame to move to a specific frame of the video by implementing Time Control Slide UI, the application crashes with the following error.

    This works fine on iOS. We've seen this happen on certain Android devices. (Samsung Galaxy Note 9 / Samsung Galaxy Fold 3, etc.)

    Unity Version is 2020.3.38f1(LTS)


    2022-10-14 10:32:29.361 21233-25648/? E/CRASH: pid: 21233, tid: 25648, name: NuCachedSource2 >>> com.chbreeze.jikbang4a:Unity <<<
    2022-10-14 10:32:30.393 21233-24418/? E/AndroidRuntime: FATAL EXCEPTION: UnityMain
    Process: com.chbreeze.jikbang4a:Unity, PID: 21233
    java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Version '2020.3.38f1 (8f5fde82e2dc)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
    Build fingerprint: 'samsung/crownlteks/crownlteks:10/QP1A.190711.020/N960NKSU3FUE1:user/release-keys'
    Revision: '28'
    ABI: 'arm64'
    Timestamp: 2022-10-14 10:32:29+0900
    pid: 21233, tid: 25648, name: NuCachedSource2 >>> com.xxxxxx.xxxxxx:Unity <<<
    uid: 10601
    signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
    x0 0000000000000000 x1 0000000000006430 x2 0000000000000006 x3 00000077651fb8f0
    x4 6066646d1f396d60 x5 6066646d1f396d60 x6 6066646d1f396d60 x7 0000000000000028
    x8 00000000000000f0 x9 0000007981f555e0 x10 0000000000000000 x11 0000000000000001
    x12 0000000000000020 x13 000000006348bc2d x14 0013b05864fb5714 x15 0000472122754ce0
    x16 00000079820238c0 x17 0000007982000880 x18 000000775579a000 x19 00000000000000ac
    x20 00000000000052f1 x21 00000000000000b2 x22 0000000000006430 x23 00000000ffffffff
    x24 00000077651fc020 x25 00000077651fc020 x26 00000077651fc020 x27 00000000000fd000
    x28 ffffffffffffffff x29 00000077651fb9a0
    sp 00000077651fb8d0 lr 0000007981fb4330 pc 0000007981fb4360

    backtrace:
    #00 pc 0000000000083360 /apex/com.android.runtime/lib64/bionic/libc.so (abort+176) (BuildId: 3f350ca06c3b80560f65755286daf320)
    #01 pc 0000000000090050 /system/lib64/libstagefright.so (BuildId: eb5199d36c819a6924047a8b8ad33cfb)
    #02 pc 0000000000090088 /system/lib64/libstagefright.so (BuildId: eb5199d36c819a6924047a8b8ad33cfb)
    #03 pc 000000000017be18 /system/lib64/libstagefright.so (android::NuCachedSource2::restartPrefetcherIfNecessary_l(bool, bool)+184) (BuildId: eb5199d36c819a6924047a8b8ad33cfb)
    #04 pc 000000000017bbe8 /system/lib64/libstagefright.so (android::NuCachedSource2::readInternal(long, void*, unsigned long)+200) (BuildId: eb5199d36c819a6924047a8b8ad33cfb)
    #05 pc 000000000017b8ec /system/lib64/libstagefright.so (android::NuCachedSource2::onRead(android::sp<android::AMessage> const&)+220) (BuildId: eb5199d36c819a6924047a8b8ad33cfb)
    #06 pc 000000000017b224 /system/lib64/libstagefright.so (BuildId: eb5199d36c819a6924047a8b8ad33cfb)
    #07 pc 000000000001a960 /system/lib64/libstagefright_foundation.so (android::AHandler::deliverMessage(android::sp<android::AMessage> const&)+48) (BuildId: eb2f37e7f27242e991ac1693077ab441)
    #08 pc 000000000001e4a4 /system/lib64/libstagefright_foundation.so (android::AMessage::deliver()+100) (BuildId: eb2f37e7f27242e991ac1693077ab441)
    #09 pc 000000000001b3cc /system/lib64/libstagefright_foundation.so (android::ALooper::loop()+564) (BuildId: eb2f37e7f27242e991ac1693077ab441)
    #10 pc 0000000000013828 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+312) (BuildId: 4ad07d8bd57f4fc98fe8072b725d570a)
    #11 pc 00000000000f1854 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+140) (BuildId: 731918c0319e36309fb70abc5a832c96)
    #12 pc 00000000000e3b24 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: 3f350ca06c3b80560f65755286daf320)
    #13 pc 0000000000085330 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 3f350ca06c3b80560f65755286daf320)

    at libc.abort(abort:176)
    at libstagefright.0x90050(Native Method)
    at libstagefright.0x90088(Native Method)
    at libstagefright.android::NuCachedSource2::restartPrefetcherIfNecessary_l(bool, bool)(restartPrefetcherIfNecessary_l:184)
    at libstagefright.android::NuCachedSource2::readInternal(long, void*, unsigned long)(readInternal:200)
    at libstagefright.android::NuCachedSource2::onRead(android::sp<android::AMessage> const&)(onRead:220)
    at libstagefright.0x17b224(Native Method)
    2022-10-14 10:32:30.951 972-1209/? E/InputDispatcher: channel 'a7a67c6 com.chbreeze.jikbang4a/com.zigbang.zed.MainUnityActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    2022-10-14 10:32:30.975 972-2999/? E/WindowManager: win=Window{a7a67c6 u0 com.chbreeze.jikbang4a/com.zigbang.zed.MainUnityActivity EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.AppWindowToken.destroySurfaces:1249 com.android.server.wm.AppWindowToken.destroySurfaces:1230 com.android.server.wm.WindowState.onExitAnimationDone:5189 com.android.server.wm.-$$Lambda$01bPtngJg5AqEoOWfW3rWfV7MH4.accept:2 java.util.ArrayList.forEach:1262 com.android.server.wm.AppWindowToken.onAnimationFinished:3941 com.android.server.wm.AppWindowToken.commitVisibility:914


    my code is like this

    Code (CSharp):
    1. // Silder UI Touch Event -----------------------------------------
    2. public void OnPointerDown(PointerEventData e)
    3. {
    4.         if (seekCoroutine != null) {
    5.             StopCoroutine(seekCoroutine);
    6.             seekCoroutine = null;
    7.         }
    8.  
    9.         dragging = true;
    10.         videoPlayer.Pause();
    11. }
    12.  
    13. public void OnPointerUp(PointerEventData e)
    14. {
    15.         float seekValue = GetComponent<Slider>().normalizedValue;
    16.  
    17.         Seek(seekValue);
    18. }
    19. // ----------------------------------------- Silder UI Touch Event
    20.  
    21. // Seek Function calling from UI Event -----------------------------------------
    22. public void Seek(float seek)
    23. {
    24.     seekFrame = videoPlayer.frame = (long)(Mathf.Clamp01(seek) * videoPlayer.frameCount);
    25. }
    26.  
    27. // VideoPlayer.seekComplete Action -----------------------------------------
    28. void OnSeekComplete(VideoPlayer source)
    29. {
    30.         source.Play();
    31. }
    32.  
     
    Last edited: Oct 18, 2022
    skudgee likes this.
  2. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    375
    I don't see anything wrong with your code. Can you report this? We will investigate the issue.
     
  3. leadhouse

    leadhouse

    Joined:
    Feb 5, 2020
    Posts:
    1
    I have the same issue.
    However, it does happen when I do use the VideoPlayer.Stop() function or when the videoPlayer is destroyed.

    Tested on 5 devices, all Samsung.
    - Crash on: Android 10 , Android 12 (x2)
    - No issue on: Android 8 (x2)

    Builds done on:
    - 2 PC with version 2019.4.40f1, 2020.3.40f1, 2020.3.41f1, 2021.3.13f1, 2022.1.22f1
    - 1 MAC: 2021 LTS

    No crash when Target API level 30 -- Crash on API level 31 and 32

    **Steps to reproduce**:
    - Start new Project, 3d core template
    - In the default scene, add a **VideoPlayer** + **raw image** + 2 buttons
    - In project, create a render texture
    - Link VideoPlayer target texture to raw image
    - Link render texture to raw image
    - Use a basic script to prepare movie + 2 functions to be linked to button (VideoPlayer.Play(), VideoPlayer.Stop()) + url (https://www.abc.com/movie.mp4)
    - Build Android with the target api level set to 31 (or 32)
    Will crash when button Stop pressed.

    I did try:
    - VideoPlayer.Pause() before VideoPlayer.Stop()
    - Set VideoPlayer.frame to 0
    - Set VideoPlayer.targetTexture to null,
    - adding delay (wait next frame, wait a few seconds after "unloading steps")
    - Different Videos from different host. (all mp4)
    - Seem ok for on device file
     

    Attached Files:

  4. snorrsi

    snorrsi

    Joined:
    Jan 30, 2017
    Posts:
    12
    @The_Island @leadhouse have the same issue.
    Videoplayer works fine in 2021.3.11f1 but in next version 2021.3.12f1 it is broken, atleast Stop and Destroy are broken which make the Videoplayer fully unusable.
    Only tested the latest 2022.1.22f1 where it was broken also as mentioned, guess it broke around the same time or earlier.

    did anyone create an issue about this ?
     
  5. skudgee

    skudgee

    Joined:
    Jun 17, 2015
    Posts:
    5
    Same problem here !
    Unity 2021.2.5f1 work just fine but 2021.3.12(LTS) cannot handle the Stop() on video from URL (crash app on Android build with android target API 31).

    - Every build with android target API 30 or less works (video can be stopped)
     
  6. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    375
    Did anyone report this bug? I don't have a phone with an API 31+, so I was hoping the QA could check it out. Thanks!
     
  7. snorrsi

    snorrsi

    Joined:
    Jan 30, 2017
    Posts:
    12
    @The_Island I haven't .. btw VideoPlayer crashes on Android 11 (API 30) when target version is API 33 using Unity 2021.3.12f1 or 2021.3.13f1 (or 2022.1.22f1)
     
  8. Aupuma

    Aupuma

    Joined:
    Feb 15, 2017
    Posts:
    37
    Same problem here with Unity 2021.3.15f1, the video crashes the app 1/2 seconds after stopping it
     
    ArthurMWM likes this.
  9. ehudcandivore

    ehudcandivore

    Joined:
    Jul 18, 2018
    Posts:
    10
    same here, 2021.3.14f1 + android target 33. Any update/plans for a fix?
     
  10. kazak_tm

    kazak_tm

    Joined:
    Sep 7, 2021
    Posts:
    12
  11. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    375