UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

[iOS] Crash when attempting to show video soon after scene loads

Open SamJenkinsAim opened this issue 6 months ago • 3 comments

Unity version

2022.3.53f1

Unity editor platform

macOS

AVPro Video edition

Core

AVPro Video version

3.2.5

Device hardware

iPhone 14 pro,

Which iOS version are you using?

18.3.2

Texture format

BGRA

Audio output

System Direct

Any other Media Player component configuration required to reproduce the issue.

No response

Which output component(s) are you using?

Display uGUI

Any other component configuration required to reproduce the issue.

No response

The issue

Noticing a crash on our app when a video begins playing. This video is part of a news carousel item and is one of the first items shown when launching in the game. The crash happens when the video is intended to play immediately upon scene loading. When the video plays after some time, we do not notice the crash. We make the call to play the video once we receive the FirstFrameReady or ReadyToPlay events associated with MediaPlayer.

Obviously if this is a timing issue around playing the video too quickly, we can adjust in our code, but I am creating this issue in case this is a bigger issue that needs looking at.

Media information

No response

Log output

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem can occupy only one position in a player's queue at a time.'
*** First throw call stack:
(0x18371e5fc 0x180c99244 0x195611fa0 0x126ae8f90 0x1824071e0 0x182406e88 0x1824063ac 0x18233e444 0x18233e138 0x18233dd48 0x195606c40 0x1956066e0 0x195606fcc 0x195611f30 0x126adfbc0 0x126af9b95 0x126afbff9 0x126b074f5 0x126afc16d 0x18f04be39)
Uncaught exception: NSInvalidArgumentException: An AVPlayerItem can occupy only one position in a player's queue at a time.
(
	0   CoreFoundation                      0x000000018371e608 0013A8B1-2524-3534-B5BA-681AAF18C798 + 185864
	1   libobjc.A.dylib                     0x0000000180c99244 objc_exception_throw + 88
	2   AVFCore                             0x0000000195611fa0 3E5B905F-51AC-350B-B32D-54BB9B116CB1 + 221088
	3   UnityFramework                      0x0000000126ae8f90 AVPUnityRegisterPlugin + 84104
	4   Foundation                          0x00000001824071e0 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 1122784
	5   Foundation                          0x0000000182406e88 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 1121928
	6   Foundation                          0x00000001824063ac E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 1119148
	7   Foundation                          0x000000018233e444 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 300100
	8   Foundation                          0x000000018233e138 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 299320
	9   Foundation                          0x000000018233dd48 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 298312
	10  AVFCore                             0x0000000195606c40 3E5B905F-51AC-350B-B32D-54BB9B116CB1 + 175168
	11  AVFCore                             0x00000001956066e0 3E5B905F-51AC-350B-B32D-54BB9B116CB1 + 173792
	12  AVFCore                             0x0000000195606fcc 3E5B905F-51AC-350B-B32D-54BB9B116CB1 + 176076
	13  AVFCore                             0x0000000195611f30 3E5B905F-51AC-350B-B32D-54BB9B116CB1 + 220976
	14  UnityFramework                      0x0000000126adfbc0 AVPUnityRegisterPlugin + 46264
	15  UnityFramework                      0x0000000126af9b95 AVPUnityRegisterPlugin + 152717
	16  UnityFramework                      0x0000000126afbff9 AVPUnityRegisterPlugin + 162033
	17  UnityFramework                      0x0000000126b074f5 AVPUnityRegisterPlugin + 208365
	18  UnityFramework                      0x0000000126afc16d AVPUnityRegisterPlugin + 162405
	19  libswift_Concurrency.dylib          0x000000018f04be39 B4CA1325-80CD-3D06-937C-00C53AD9F2AA + 433721
)


* thread #71, queue = 'com.apple.root.user-initiated-qos.cooperative', stop reason = signal SIGABRT
  * frame #0: 0x00000001d4e572d4 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x000000020e4b159c libsystem_pthread.dylib`pthread_kill + 268
    frame #2: 0x000000018b56cb08 libsystem_c.dylib`abort + 128
    frame #3: 0x000000020e3d75b8 libc++abi.dylib`abort_message + 132
    frame #4: 0x000000020e3c5bac libc++abi.dylib`demangling_terminate_handler() + 348
    frame #5: 0x0000000180c9b2c4 libobjc.A.dylib`_objc_terminate() + 156
    frame #6: 0x000000020e3d687c libc++abi.dylib`std::__terminate(void (*)()) + 16
    frame #7: 0x000000020e3d9dfc libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 88
    frame #8: 0x000000020e3d9da4 libc++abi.dylib`__cxa_throw + 92
    frame #9: 0x0000000180c993ac libobjc.A.dylib`objc_exception_throw + 448
    frame #10: 0x0000000195611fa0 AVFCore`-[AVPlayer _insertItem:afterItem:] + 632
    frame #11: 0x0000000126ae8f90 UnityFramework`___lldb_unnamed_symbol1196412 + 320
    frame #12: 0x00000001824071e0 Foundation`closure #1 @Sendable (__C.NSObject, Foundation.NSKeyValueObservedChange<Any>) -> () in Foundation._KeyValueCodingAndObserving.observe<τ_0_0>(_: Swift.KeyPath<τ_0_0, τ_1_0>, options: __C.NSKeyValueObservingOptions, changeHandler: (τ_0_0, Foundation.NSKeyValueObservedChange<τ_1_0>) -> ()) -> Foundation.NSKeyValueObservation + 468
    frame #13: 0x0000000182406e88 Foundation`function signature specialization <Arg[0] = Dead, Arg[3] = Dead> of Foundation.NSKeyValueObservation.Helper._swizzle_me_observeValue(forKeyPath: Swift.Optional<Swift.String>, of: Swift.Optional<Any>, change: Swift.Optional<Swift.Dictionary<__C.NSString, Any>>, context: Swift.Optional<Swift.UnsafeMutableRawPointer>) -> () + 1044
    frame #14: 0x00000001824063ac Foundation`@objc Foundation.NSKeyValueObservation.Helper._swizzle_me_observeValue(forKeyPath: Swift.Optional<Swift.String>, of: Swift.Optional<Any>, change: Swift.Optional<Swift.Dictionary<__C.NSString, Any>>, context: Swift.Optional<Swift.UnsafeMutableRawPointer>) -> () + 160
    frame #15: 0x000000018233e444 Foundation`NSKeyValueNotifyObserver + 252
    frame #16: 0x000000018233e138 Foundation`NSKeyValueDidChange + 384
    frame #17: 0x000000018233dd48 Foundation`NSKeyValueDidChangeWithPerThreadPendingNotifications + 156
    frame #18: 0x0000000195606c40 AVFCore`__109-[AVPlayer _runOnIvarAccessQueueOperationThatMayChangeCurrentItemWithPreflightBlock:modificationBlock:error:]_block_invoke_2 + 1004
    frame #19: 0x00000001956066e0 AVFCore`-[AVSerializedMostlySynchronousReentrantBlockScheduler scheduleBlock:] + 312
    frame #20: 0x0000000195606fcc AVFCore`-[AVPlayer _runOnIvarAccessQueueOperationThatMayChangeCurrentItemWithPreflightBlock:modificationBlock:error:] + 376
    frame #21: 0x0000000195611f30 AVFCore`-[AVPlayer _insertItem:afterItem:] + 520
    frame #22: 0x0000000126adfbc0 UnityFramework`___lldb_unnamed_symbol1196249 + 1288
    frame #23: 0x0000000126af9b94 UnityFramework`___lldb_unnamed_symbol1196946
    frame #24: 0x0000000126afbff8 UnityFramework`___lldb_unnamed_symbol1196961
    frame #25: 0x0000000126b074f4 UnityFramework`___lldb_unnamed_symbol1197240
    frame #26: 0x0000000126afc16c UnityFramework`___lldb_unnamed_symbol1196966

SamJenkinsAim avatar May 07 '25 18:05 SamJenkinsAim