companion icon indicating copy to clipboard operation
companion copied to clipboard

V3.5.1 Trigger not working correctly

Open ChrisSW58 opened this issue 10 months ago • 11 comments

Is this a bug in companion itself or a module?

  • [x] I believe this to be a bug in companion

Is there an existing issue for this?

  • [x] I have searched the existing issues

Describe the bug

A difficult one to explain and it may be something stupid I am doing.

I have a button which has a press action set, and a release action set. The trigger action set sets a variable to 1 which calls a trigger. Releasing the button resets the same variable to 0. When the button is pressed all works well. When the button is called using the trigger press and release, nothing happens. Or at least the variable is set at 0 and the trigger has not executed, so maybe it's getting to 0 before the trigger recognises the change? So how do I make this call which worked fine in previous versions? If I split into 2 separate calls and add a wait it works, but is this what I have do do for every call to a button with a release action? Happy to be educated!

Steps To Reproduce

  1. Create a button with a few actions, and setting a variable to be tested by a trigger.
  2. Add release section to reset the trigger
  3. Create a trigger to react when the variable is set.
  4. Call the button with a trigger press and release call.

Expected Behavior

The trigger should action in the same was as when the button is pressed and as it worked in previous versions.

Environment (please complete the following information)

- OS: Sequoia 15.3.1 
- Browser: Safari
- Companion Version: 3.5.1 Stable (Mac arm)

Additional context

No response

ChrisSW58 avatar Feb 10 '25 21:02 ChrisSW58

In what version did this last work? I can reproduce this issue in 3.2.2 or 3.5.1. Unless you were hitting the bug https://github.com/bitfocus/companion/issues/3217 or #3186 where conditions were being ignored

Julusian avatar Feb 11 '25 00:02 Julusian

Good question! It may never have worked correctly as I did not call the button from another routine until the current work I have just completed! What way is it intended to be used?

ChrisSW58 avatar Feb 11 '25 00:02 ChrisSW58

The issue you are hitting is that the release gets triggered immediately after the press. meaning the variable has only changed momentarily. And we are debouncing the variable changes, to avoid drawing and excess trigger executions when in situations like module startup and many variables are changing all at once in a short period of time. Which means that the debounce only sees the variable change from 0 to 0

The code has been this way since 3.0 as far as I can tell.

What way is it intended to be used?

I don't follow, each portion of this has its own uses, but its just when combined in this way that it doesnt behave quite as could be expected.

I guess we could change the press and release action to have a customisable press duration? that would at least allow you to avoid this

Julusian avatar Feb 11 '25 17:02 Julusian

Interesting. So I have an array of buttons - 4 presets to each of 6 cameras. Press and release, the camera moves to the preset. Press and hold, and the preview fills the entire ATEM monitor until it is released. Since 3.3.1, or before, I have been able to use the following code on the preset button:

  • Set variable A
  • Set variable B
  • Set variable C (Set trigger)
  • Recall camera preset

and then a release with a Set Variable C which resets the trigger

and I have been able to call that with Press and Release from numerous pages and it has always worked.

Now in 3.5.1 (and probably 3.5.0) the variables A and B are set correctly, and the recall happens but as we have found, variable C gets set and reset before the trigger detects it. So something has changed time wise to speed up that process.

Does that make sense?

(Variable C moves the preset into the ATEM Preview window)

ChrisSW58 avatar Feb 11 '25 18:02 ChrisSW58

Then I guess I am doing something wrong with my testing, because I was getting the same behaviour in 3.2 as 3.5 yesterday. Could you provide a page export and a trigger, so I can look into exactly what you have setup in 3.3?

Julusian avatar Feb 11 '25 18:02 Julusian

Hmmm...what I HAVE done, for better management of the code is to add a Logic: AND on the trigger condition.... could that be the cause?

ChrisSW58 avatar Feb 11 '25 18:02 ChrisSW58

Here are the triggers and the two pages: the triggers you look at are called Auto - Preview - Camera x where x is the Camera number 1-6

Page 21 is the main screen with the 24 presets. Page 25 is the call to which I have explicitly added the variable C call (if that makes sense.

Triggers and screens.zip

ChrisSW58 avatar Feb 11 '25 18:02 ChrisSW58

I really can't see what you could have done differently to see different behaviour than my testing in 3.2

I've now tried 3.3 too, and still getting the same.

For context, my full test setup is:

Image

Image

Image

the collapsed actions are irrelevant, just trying to pad things out to match what you had.

If I press 1/1/4 directly, it works, but pressing 1/1/5 which simply triggers 1/1/4 it doesnt.

Maybe you can spot what I have done differently?

Julusian avatar Feb 11 '25 19:02 Julusian

OK - here are the 2 offending pages and everything cut back. Page 1 has the button. Press it and look at the trigger Auto - Preview - Camera 1. Note the date and time. Now press next page, and press the button on the bottom line saying Test This. The trigger does not fire. D you get the same as me now?

Chris-iMac-4.local_2025-02-11-2010.companionconfig.zip

ChrisSW58 avatar Feb 11 '25 20:02 ChrisSW58

Where can I get Companion 3.3.1 to see what happens there with the old code?

ChrisSW58 avatar Feb 11 '25 20:02 ChrisSW58

On a higher level, we need to have a differentiator between Press and Release and press followed by release. What options do we have? At the moment I have to code Trigger, wait, and then release for each button call. Bit of a pain but it seems to work. Can we slow the release action for, say, 250ms, to allow the trigger to action it? (250 works for me)

ChrisSW58 avatar Feb 11 '25 20:02 ChrisSW58