Skip to content
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

[ASVideoNode] Time observer fix #604

Merged
merged 2 commits into from
Oct 6, 2017
Merged

[ASVideoNode] Time observer fix #604

merged 2 commits into from
Oct 6, 2017

Conversation

flovouin
Copy link
Contributor

@flovouin flovouin commented Oct 5, 2017

Hi guys,

I was adding a custom seek bar to a video node, and noticed that when changing the played video, I was still getting didPlayToTimeInterval delegate calls for the old video.

You can easily see what I mean in this sample project.
The video is reloaded after 2 seconds, and after that, the progress bar goes crazy, switching back and forth between the time info of the two players.
Not releasing the time observer also means that the former video keeps playing in the background, and hence seems to increase CPU consumption (twice the load on my device).

The fix is simple: actually release the time observer when removing the player. Because the observer is linked to the player, I just moved allocation/deallocation of the observer to addPlayerObservers/removePlayerObservers.

Tell me what you think,
Cheers,

Flo

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! 🙏

Copy link
Contributor

@maicki maicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nguyenhuy I think at some point would be valuable to go through ASVideoNode and add review the __locked_ / locking strategy. As e.g. I think addPlayerObservers etc should be called with lock held.

@nguyenhuy
Copy link
Member

@maicki Yeap, agreed!

@nguyenhuy nguyenhuy merged commit 4a203db into TextureGroup:master Oct 6, 2017
@flovouin flovouin deleted the VideoNodeObserverFix branch December 21, 2017 17:44
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
* [ASVideoNode] Move time observer handling to player observers methods.

* Update CHANGELOG.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants