New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making player optional and cleaning up player instance #83
Conversation
Can one of the admins verify this patch? |
Hi @SachinAhujaGit, |
@SachinAhujaGit thank you for that - we're looking into it and get back with a solution/merge shortly |
@SachinAhujaGit thanks for the feedback.
cc: @itaykinnrot, @ElizaSapir |
@galorlanczyk I shared access to our BitBucket repo with you. You can find the video components here: https://bitbucket.org/grahamdigital/newsreader.ios/src/9078d18c955d989eba7a46ea9e9da6d30751973a/NewsReader/customComponents/VideoPlayer/VideoPlayerViewController.m?at=master&fileviewer=file-view-default Please let us know if you need more examples. We also have a public beta that we can share that reproduces this problem. |
@newmaniese i receive access denied when trying to enter the link, any other ways I could see an example? |
I shared access with the username |
@newmaniese I tried to look at the class you sent me, it seems fine, but I can't seem to find the steps of the error you guys mentioned.
|
Certainly, I sent a TestFlight build to @itaykinnrot and @ElizaSapir and also attempted a guess at your email, but might have been wrong. It is intermittent, but the most consistent instance of us running into this issue is to play the video on the homepage, then to open an article with a video (Right now "Why was a woman who delivered..."), swipe right to play another video. That video doesn't play, due to this issue. You can also feel the app getting sluggish as there are some memory implications here. The fix here might be a little brute force, as it just marks everything for garbage collection. Another fix would be to clean up references to the other classes that are invoked. I haven't dug in as far as @SachinAhujaGit, but I assume too there are IMA variables that are attached to this class that aren't cleared on destroy, which is probably the actual cause of the issue. |
@newmaniese hey, The app looks great :) We tried to reproduce the issue on your app with no success. If you are talking about But as we see video always plays, we got black screen only twice when there was some issue with ad tag url and google server. So let's make it clear to try and reproduce it on our side:
Thanks! cc @galorlanczyk , @itaykinnrot , @OrenMe |
@ElizaSapir, we have both issues, this proposed fix clears both. To reproduce, just click through a few videos in the app, you will feel the app bog down and eventually see the player become blank. If it were only an IMA issue, you should sometimes see this happen on the first or second instance of the video player. Instead it is always deeper within the application. The black screen eventually crashes the entire player (we catch and reset it). The memory leak is certainly with the IMA plugin, disabling it, we cannot reproduce. I am attempting to pull some allocation logs so you can see each instance of the video player holds onto a bunch of memory. Replacing the class to nil allows all of this memory to be cleaned and fixes both issues. Like I said, this is brute force, but effective. |
@newmaniese, @SachinAhujaGit Hey, After deep examination of the issue I have found a bug with Apple's interoperability in Swift which causes a memory leak. The issue is caused when initializing a Swift object from a protocol.Type with the @objc attribute (happens both in swift and objc projects using swift), this causes the object to automatically receive an extra strong reference and therefore it never gets deallocated. I already implemented a solution and will update you when the new version will be available. cc: @ElizaSapir, @itaykinnrot, @OrenMe |
@newmaniese, @SachinAhujaGit Hey, We released a new version with the fix inside + made some changes with IMA. For the fix commit: 49f150c Thank you for your cooperation. |
Intermittently the player instance doesn't clean up and leads to error loading subsequent videos. Setting the current item to nil in destroy() function of AVPlayerEngine.swift fixes this issue.
The app crashes as IMA plugin is trying to access the removed player when the player instance is removed as the ad is loading. So, the player should be made optional.