Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

iOS/Video: Seeking is not possible to time {INVALID}

Discussion in '5.6 Beta' started by StarManta, Mar 27, 2017.

  1. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I unpredictably get the following error when playing my video-centric app on iOS.

    By "unpredictably", I mean I get the exception, then ignore it and work on something else, then build it later and it works. However, simply building the same app twice does not not fix it. I have no idea what the pattern could be.

    Code (csharp):
    1. 'NSInvalidArgumentException', reason: '*** -[AVPlayerItem seekToTime:toleranceBefore:toleranceAfter:completionHandler:] Seeking is not possible to time {INVALID}'
    2. *** First throw call stack:
    3. (0x1d29cdf7 0x1c4ff077 0x23a0792d 0x239f4287 0x290c6f4 0x2912d78 0x26fe500 0x15bc998 0x3dd690 0x3db7f8 0x1d32518 0x2e4b654 0x2ee9954 0x2581944 0x257cd38 0x282d2cc 0x21eef64 0x21eeefc 0x23d68c8 0x2931d9c 0x392fc 0x392b8 0x39178 0x3b02a7b 0x2006d551 0x2006d399 0x1f4fd1c9 0x1d4f0f95 0x1d245047 0x1d258e0f 0x1d2585fb 0x1d256801 0x1d1a5533 0x1d1a5341 0x1e97cbfd 0x223b3e67 0x223ae591 0x24cb8 0x1c96f50b)
    4. libc++abi.dylib: terminating with uncaught exception of type NSException
    This doesn't seem to contain any useful debug information that I can use to find the issue on my end, so I come here to ask for guidance on the issue.

    I have wrapped up all of the possible suspect function calls to the VideoPlayer class with try-catch statements to no avail, suggesting to me that this happens outside the world of C# entirely.
     
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi!

    I see the seekTo function called from 3 places in the iOS implementation:
    1. When the video loops back to start again if loop mode is enabled.
    2. When the playback resumes after having stalled (because the system could not keep up due to the decoding of this video being too demanding)
    3. When you explicitly seek.
    Can you tell us which one of these 3 operations your app is doing? Loop, stall or seek? If it's the seek, then are you passing in mixing seeks by frame (VideoPlayer.frame = x) and by time (VideoPlayer.time = y) ?

    In this last scenario, I can find to opportunities for an incorrect time to make it down to the low-level seek function: 1) alternating between seek-by-frame and seek-by-time may introduce a bad time value (easy to fix on our side) or 2) you are passing an invalid time value (negative, nan, ...).

    Can you give us more details? Ideally, you'd log a bug about this. I'm always happy to help in the forum threads but eventually I may lose track of the discussions and the problem will fall through the cracks...

    Thanks for reporting this!

    Dominique
    A/V developer at Unity
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Thanks for the reply. I know a bug report is preferred, but I'm averse to them here because I can't generally submit a repro case or project file on account of IP restrictions with my company.

    Definitely no looping, this happens the instant the video starts.
    I'd be surprised if this were happening because, again, it's the instant the video starts.
    Seeking, I do a fair amount (always by setting .time). However, negative and NaN values here were one of the first things I checked for, and I can't find any cases where I'm setting the time to any such values. I can take another crack at this and see if I can get you more information on that (like which values specifically it's trying to set - my expectation here would be either 0 or 0.03)
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Update: Debug logs indicate that I got this error (in this case) immediately after setting .time to 0.080412
     
  5. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Too bad for us, but I understand. If this is just about protecting the video files though, you can replace them with non-protected content.

    OK, thanks for helping narrow it down.

    Very good to know. Seeking by frame requires the frame rate to be known so if you did this without waiting for the video to be prepared, then you may get into division by zero issues (something we'd have to protect against of course).

    Can you tell me at what point you do your seek? Before/after Prepare() is called, before/after Play() is called? A sequence of events of what you are doing with the VideoPlayer would help figure out what can go wrong.

    Dominique
     
  6. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    It's after Prepare() has been called, but I just checked, and in the log just before the crash, isPrepared is not yet true. Now building to see if just checking against .isPrepared before setting the time resolves the issue...
     
  7. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Confirmed, that was it. If I check .isPrepared before trying to set .time, the issue does not occur. Looks like that divide by zero was the issue.
     
  8. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Excellent, thanks for testing! I'll slip this in the 5.6.x fixes at the next occasion!

    Dominique
     
    StarManta likes this.