Skip to content

Commit 168f57e

Browse files
authored
Fix timer running late (#685)
1 parent 4d8691c commit 168f57e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/membrane/core/element.ex

+13
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,20 @@ defmodule Membrane.Core.Element do
256256
end
257257

258258
defp do_handle_info(Message.new(:timer_tick, timer_id), state) do
259+
# Guarding the `TimerController.handle_tick/2` invocation is
260+
# required since there might be a case in which `handle_tick`
261+
# callback's implementation returns demand action.
262+
# In this scenario, without this guard, there would a possibility that
263+
# the `handle_buffer` would be called immediately, returning
264+
# some action that would affect the timer and the original state
265+
# of the timer, set with actions returned from `handle_tick`,
266+
# would be overwritten with that action.
267+
#
268+
# For more information see: https://github.com/membraneframework/membrane_core/issues/670
269+
state = %{state | supplying_demand?: true}
259270
state = TimerController.handle_tick(timer_id, state)
271+
state = %{state | supplying_demand?: false}
272+
state = Membrane.Core.Element.DemandHandler.handle_delayed_demands(state)
260273
{:noreply, state}
261274
end
262275

0 commit comments

Comments
 (0)