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

Quick fix for Pmono (and PmonoArtic) turning everything off in the default group #5027

Conversation

eleses
Copy link
Contributor

@eleses eleses commented Jun 18, 2020

Purpose and Motivation

Fixes #5024

Commit 83e4607 merged in PR #4787 exposed an underlying problem in Pmono's two-part cleanup setup, which can (now at least) fire a type: off event with no id set, turning everything off in the default group, e.g. as in:

Synth(\default);
PfadeOut(Pmono(\default, \dur, 0.4), 0.3).play;

This is an "emergency fix" that prevents Pmono's cleanup from firing that off event if id is still not set by the time the
cleanup is executed. (The mechanism is also inherited by PmonoArtic.)

A better solution would be to rewrite Pmono so that it doesn't register an incompletely specified cleanup at all, but that is somewhat involved given the number of variables it would need to capture in a closure.

Also this PR will very likely cause a merge conflict with the solution currently envisaged for #4806 which needs to change the previous line in that Pmono cleanup setup code (to conform to the new API for cleanups), so please merge this PR as soon as practically possible.

Types of changes

  • Bug fix

To-do list

  • Code is tested
  • All tests are passing
  • This PR is ready for review

…fault group

Commit 83e4607 merged in PR supercollider#4787 exposed an underlying problem
in Pmono's two-part cleanup setup, which can fire a `type: off` event
with no `id` set, turning everything off in the default group.

This is an "emergency fix" that prevents Pmono's cleanup from
firing that `off` event if `id` is still not set by the time the
cleanup is executed.
@eleses eleses requested a review from jamshark70 June 18, 2020 23:58
@jamshark70
Copy link
Contributor

Per #5024 (comment), there's a very high likelihood that the stopgap proposed here wouldn't be necessary. So I'd suggest to hold off on merging -- I'm guessing >90% chance of closing this one without a merge.

@eleses
Copy link
Contributor Author

eleses commented Jun 19, 2020

Per #5024 (comment), there's a very high likelihood that the stopgap proposed here wouldn't be necessary. So I'd suggest to hold off on merging -- I'm guessing >90% chance of closing this one without a merge.

Per my subsequent comment there, your proposed alternative breaks stop on Pmono, alas.

The two-part approach to Pmono cleanups is alas not looking like it can be avoided, given that downstream filters of Pmono events, including the EventStreamPlayer, have a "chicken and egg" problem with Pmono cleanups: they need to register them, but before the id is known... because the event hasn't played yet.

I know I suggested a simple closure-based solution to Pmono's cleanup, but alas it looks not feasible within the constraints of how only events are used to propagate cleanups "downstream". There's no general callback mechanism in which all streams which may want to get a new cleanup can be notified to add one.. from a callback from Event. For a closure solution to work, we'd need a broadcast version of updatePmono in which every stream (or player) that depends on that Pmono will get notified to add a cleanup to their own copy of the cleanups, after the monoNote event has played. I suppose cleanup-aware streams could do something like that using addDependant as a hack implemented in EventStreamCleanup.update, which would do that addDependant when it sees updatePmono in the event (or more generally a new dependency flag/mechanisms like that that's not particular to Pmono), but it seems a non-trivial solution that would require a fair bit of testing. (And frankly registering a possibly no-op cleanup, as we do now, doesn't look worse than registering a dependency so that a stream can get notified when a new real cleanup is actually added from an Event callback.)

So, I will be basing my PR for the general cleanup dedupe assuming this solution (5027) is in place, simply because it's a minimalist fix to the problem introduced/exposed in #4787.

@jamshark70
Copy link
Contributor

jamshark70 commented Jun 21, 2020

FWIW, I just verified that the problem is not reproducible after merging #5030, with no other changes (and stopping a regular Pmono is not broken with #5030 in place) -- unsurprising as 5030 seems to incorporate the change here.

I'll wait a bit for other feedback, but AFAICS this PR doesn't need to be merged.

@eleses
Copy link
Contributor Author

eleses commented Jun 21, 2020

unsurprising as 5030 seems to incorporate the change here

That was intentional because of (1) the potential edit conflict since they changed adjacent lines of code... and (2) I wanted to check that they work together.

However, 5030 might take substantially longer to review/approve/merge.

@dyfer
Copy link
Member

dyfer commented Feb 26, 2021

@eleses @jamshark70 should we close this then?

@jamshark70
Copy link
Contributor

jamshark70 commented Feb 27, 2021

Hm... "unsurprising as 5030 seems to incorporate the change here."

So if we keep it in 5030, then this PR would be redundant. However 5030 seems to include changes not related to CleanupThunk/CallOnce. It might be worth narrowing the scope. Actually I looked again -- apart from the discussion over the name, 5030's changes all seem germane.

I suspect we want to keep it -- a cleanup event with a nil ID is not good, regardless of how we got there.

@joshpar
Copy link
Member

joshpar commented Feb 20, 2022

@jamshark70 and @dyfer - OK to close?

@jamshark70
Copy link
Contributor

I confirmed that the issue is still reproducible in current develop, but it is not reproducible after applying #5386 (de-dup EventStreamCleanup). This was a fortunate accident -- I had applied 5386 locally to check the behavior of CallOnce().valueArray, and forgotten to switch back to develop before checking this case. It worked fine with 5386.

So, if we have a commitment to merge #5386, then this one can be closed.

@dyfer dyfer merged commit a4d8ab1 into supercollider:develop Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pdef with fading STILL dies on some streams that generate (internal) cleanup, e.g. PmonoArtic
4 participants