neekeetab / CachingPlayerItem

Play and cache media content simultaneously on your iOS device
MIT License
520 stars 89 forks source link

Crash when setting dataToRespond #13

Open ohthatsjhall opened 6 years ago

ohthatsjhall commented 6 years ago

We have a live app that sees several crashes on line 170 in the CacePlayerItem.swift file. I got a EXC_BAD_ACCESS error when trying to set dataToRespond. Any ways around this?

neekeetab commented 6 years ago

I couldn't reproduce the crash, unfortunately. Under what circumstances does this happen? Please provide steps to reproduce.

ohthatsjhall commented 6 years ago

I've only been able to recreate the issue once, although it's happening frequently to our wider user base. The crash occurred when the view the video was playing on was instantiated. As mentioned earlier, the only crash reporting I received was a EXC_BAD_ACCESS on like 170. Thanks for looking into this @neekeetab

neekeetab commented 6 years ago

The problem is there's nothing special in line 170 and EXC_BAD_ACCESS doesn't tell much either. FYI, CachingPlayerItem doesn't work well with large video files because the entire data is stored in RAM. Maybe the crashes you experience are because of you're out of memory at some point.

vergilw commented 5 years ago

@neekeetab i have the same crash, line 158 let dataToRespond = songDataUnwrapped.subdata(in: Range(uncheckedBounds: (currentOffset, currentOffset + bytesToRespond)))

Thread 1: EXC_BAD_ACCESS (code=1, address=0x115be0040)

my video duration less than 60 seconds, it happened few times. i think it's cause of "uncheckedBounds" the better way is check this bound

neekeetab commented 5 years ago

@vergilw, please give a link to the video that reproduces the crash.

vergilw commented 5 years ago

@neekeetab it won't crash every times, i think the problem is set new URL value to CachingPlayerItem when previous URL is not download finished. it didn't release some object. i'm not very sure

ealeksandrov commented 5 years ago

I also have reports for EXC_BAD_ACCESS KERN_INVALID_ADDRESS on same line and it is hard to reproduce. In my case videos are played in collection view and reused while scrolling.

Videos are less than 10 sec. Crashlytics report for says Free Ram = 421.17 MiB.

Maybe it's related to assigning new CachingPlayerItem on cell reuse while old one is still downloading or in some intermediate state.

neekeetab commented 5 years ago

Thanks for the detailed description. I'll take a look at this with the reuse case in mind when I have time. If you find the cause, it would be awesome if you could make a PR. @ealeksandrov

ealeksandrov commented 5 years ago

Sure I'll let you know if I found more details or concrete fix.