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 bug in handling actions returned from handle_tick. Deprecate handle_spec_started. #708

Merged
merged 26 commits into from
Feb 26, 2024

Conversation

FelonEkonom
Copy link
Member

@FelonEkonom FelonEkonom commented Jan 17, 2024

Closes #695
Closes #752
Relates to #753

@FelonEkonom FelonEkonom self-assigned this Jan 17, 2024
@FelonEkonom FelonEkonom force-pushed the fix-handling-actions-bug branch from 0380d86 to 3630ef2 Compare January 24, 2024 18:01
@FelonEkonom FelonEkonom force-pushed the fix-handling-actions-bug branch from 3630ef2 to 0e40638 Compare January 29, 2024 14:32
@FelonEkonom FelonEkonom force-pushed the fix-handling-actions-bug branch from 927285a to 990172b Compare January 29, 2024 16:46
@FelonEkonom FelonEkonom marked this pull request as ready for review January 31, 2024 11:46
@FelonEkonom FelonEkonom requested a review from mat-hek as a code owner January 31, 2024 11:46
@FelonEkonom FelonEkonom force-pushed the fix-handling-actions-bug branch from 4ec86bf to 47e97c9 Compare February 2, 2024 14:13
Comment on lines 40 to 43
Membrane.Logger.warning("""
Action :spec was returned from handle_spec_started/3 callback. It is suggested not to do this,
because it might lead to infinite loof of handle_spec_started/3 executions.
""")
Copy link
Member

Choose a reason for hiding this comment

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

I'd not make this a warning, as this may be a valid situation as well.


@impl CallbackHandler
def handle_end_of_actions(state) do
ChildLifeController.trigger_specs(state)
Copy link
Member

Choose a reason for hiding this comment

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

This may be problematic, as we one can do [spec: child(:foo, Foo), notify_child: {:foo, :ping}]. I think we should only delay the callback execution.

@@ -191,6 +192,9 @@ defmodule Membrane.Core.CallbackHandler do
was_handling_action? = state.handling_action?
state = %{state | handling_action?: true}

was_supplying_demand? = Map.get(state, :supplying_demand?, false)
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 that it's a temporary fix

Copy link
Member

Choose a reason for hiding this comment

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

@FelonEkonom FelonEkonom requested a review from mat-hek February 13, 2024 11:14
@FelonEkonom FelonEkonom changed the title Bug in handling actions returned from handle_tick Fix bug in handling actions returned from handle_tick. Deprecate handle_spec_started. Feb 13, 2024
@FelonEkonom FelonEkonom marked this pull request as draft February 13, 2024 11:21
@FelonEkonom FelonEkonom marked this pull request as ready for review February 13, 2024 13:26
Comment on lines 315 to 316
require Membrane.Core.Parent
Membrane.Core.Parent.bring_after_compile_check()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
require Membrane.Core.Parent
Membrane.Core.Parent.bring_after_compile_check()
@after_compile {Membrane.Core.Parent, :check_for_deprecated_callbacks}

Comment on lines 6 to 27
defmacro bring_after_compile_check() do
quote do
@after_compile {__MODULE__, :__membrane_check_deprecated_functions__}

@spec __membrane_check_deprecated_functions__(Macro.Env.t(), binary) :: :ok
def __membrane_check_deprecated_functions__(env, _bytecode) do
modules_whitelist = [Membrane.Testing.Pipeline]

if env.module not in modules_whitelist and
Module.defines?(env.module, {:handle_spec_started, 3}, :def) do
warn_message = """
Callback handle_spec_started/3 has been deprecated since \
:membrane_core v1.0.1, but it is implemented in #{inspect(env.module)}
"""

IO.warn(warn_message, [])
end

:ok
end
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
defmacro bring_after_compile_check() do
quote do
@after_compile {__MODULE__, :__membrane_check_deprecated_functions__}
@spec __membrane_check_deprecated_functions__(Macro.Env.t(), binary) :: :ok
def __membrane_check_deprecated_functions__(env, _bytecode) do
modules_whitelist = [Membrane.Testing.Pipeline]
if env.module not in modules_whitelist and
Module.defines?(env.module, {:handle_spec_started, 3}, :def) do
warn_message = """
Callback handle_spec_started/3 has been deprecated since \
:membrane_core v1.0.1, but it is implemented in #{inspect(env.module)}
"""
IO.warn(warn_message, [])
end
:ok
end
end
end
def check_for_deprecated_callbacks(env, _bytecode) do
modules_whitelist = [Membrane.Testing.Pipeline]
if env.module not in modules_whitelist and
Module.defines?(env.module, {:handle_spec_started, 3}, :def) do
warn_message = """
Callback handle_spec_started/3 has been deprecated since \
:membrane_core v1.0.1, but it is implemented in #{inspect(env.module)}
"""
IO.warn(warn_message, [])
end
:ok
end

@@ -204,9 +204,11 @@ defmodule Membrane.Pipeline do
) :: {[Action.common_actions()], state()}

@doc """
This callback is deprecated since v1.0.1.
Copy link
Member

Choose a reason for hiding this comment

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

If we deprecate the callback, I'd go for releasing the current master as v1.0.1 and release this as v1.1.0-rc0 with auto flow queues

@FelonEkonom FelonEkonom requested a review from mat-hek February 14, 2024 11:28
@FelonEkonom FelonEkonom merged commit e4305da into master Feb 26, 2024
7 checks passed
@FelonEkonom FelonEkonom deleted the fix-handling-actions-bug branch February 26, 2024 15:42
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.

Deprecate handle_spec_started/3 Bug in handling actions returned from handle_tick
2 participants