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

Fix timer running late #685

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/membrane/core/element.ex
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,20 @@ defmodule Membrane.Core.Element do
end

defp do_handle_info(Message.new(:timer_tick, timer_id), state) do
# Guarding the `TimerController.handle_tick/2` invocation is
# required since there might be a case in which `handle_tick`
# callback's implementation returns demand action.
# In this scenario, without this guard, there would a possibility that
# the `handle_buffer` would be called immediately, returning
# some action that would affect the timer and the original state
# of the timer, set with actions returned from `handle_tick`,
# would be overwritten with that action.
#
# For more information see: https://github.com/membraneframework/membrane_core/issues/670
state = %{state | supplying_demand?: true}
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a comment explaining why we do this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

state = TimerController.handle_tick(timer_id, state)
state = %{state | supplying_demand?: false}
state = Membrane.Core.Element.DemandHandler.handle_delayed_demands(state)
{:noreply, state}
end

Expand Down