# Help debugging?

**URL:** <https://mworks.discourse.group/t/help-debugging/405>\
**Category:** Support\
**Created:** [July 13, 2017, 2:47pm UTC](https://mworks.discourse.group/t/help-debugging/405 "2017-07-13T14:47:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 13, 2017, 2:47pm UTC](https://mworks.discourse.group/t/help-debugging/405/1 "2017-07-13T14:47:44Z")

</div>

I have another one: the stimulus “syncFlash” is, on rare occasions, either double playing, or jittering, or getting a blank frame injected, or something. If you have a chance, can you take a look at the code to see if you see any red flags in terms of how I’ve written the code related to that stimulus?

Thanks,  
Evan

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 13, 2017, 3:16pm UTC](https://mworks.discourse.group/t/help-debugging/405/2 "2017-07-13T15:16:10Z")

</div>

Hi Evan,

I don’t see anything in your experiment that looks suspicious.

> “syncFlash” is, on rare occasions, either double playing, or jittering, or getting a blank frame injected, or something

Do you mean that you’ve seen it do all of these things, or are you just saying that it looks wrong and you don’t know why?

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 13, 2017, 5:57pm UTC](https://mworks.discourse.group/t/help-debugging/405/3 "2017-07-13T17:57:34Z")

</div>

It looks like the “syncInterval” stimuli were getting cut short for some  
reason, leading to two “syncFlash” stimuli being played in rapid  
succession. My guess is there was some race condition happening with the  
“stimEnding” variable shared by the “syncFlash” and “syncInterval” stimuli.  
The experiment is supposed to work like this:

1. stimEnding is reset to 0, and syncFlash plays
2. when the last syncFlash frame is queued, stimEnding gets set to 1
3. when stimEnding == 1, reset stimEnding to 0, dequeue syncFlash and  
play syncInterval
4. when the last syncInterval frame is queued, stimEnding gets set to 1,  
sending execution back to 1.

The only explanation I can think of is that somehow stimEnding isn’t  
properly being set to 0. Is it possible that the syncFlash stimulus is  
_resetting_ the stimEnding variable to 1 before the stimulus update  
completes? I tried breaking out stimEnding into “flashEnding” and  
“intervalEnding” to eliminate the possibility of this happening, and I’m no  
longer seeing the glitch.

Evan

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 13, 2017, 7:37pm UTC](https://mworks.discourse.group/t/help-debugging/405/4 "2017-07-13T19:37:13Z")

</div>

> My guess is there was some race condition happening with the  
> “stimEnding” variable shared by the “syncFlash” and “syncInterval” stimuli.

That makes sense, although I admit I can’t find the error in your experiment, either.

> I tried breaking out stimEnding into “flashEnding” and  
> “intervalEnding” to eliminate the possibility of this happening, and I’m no  
> longer seeing the glitch.

That sounds like a good fix.

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 25, 2017, 8:11pm UTC](https://mworks.discourse.group/t/help-debugging/405/5 "2017-07-25T20:11:45Z")

</div>

Hi Chris,

I just read through the [recent issue](https://mworks.discourse.group/discussions/problems/269) that Xiang Li was having, and it seems like I was running into the same issue. I had two alternating stimuli that shared the same “stimEnding” variable. However, you said you couldn’t find the error. Is it not the same problem? I can re-send the code if that helps.

Thanks,  
Evan

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 26, 2017, 7:40pm UTC](https://mworks.discourse.group/t/help-debugging/405/6 "2017-07-26T19:40:11Z")

</div>

Hi Evan,

Yes, it’s probably the same issue. Let me see if I can rework things in the frame list stimulus so that the “ending” variable never gets set more than once.

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 26, 2017, 7:48pm UTC](https://mworks.discourse.group/t/help-debugging/405/7 "2017-07-26T19:48:11Z")

</div>

> Let me see if I can rework things in the frame list stimulus so that the “ending” variable never gets set more than once.

Another option would be to make it _always_ produce the “bug” behavior, if  
that’s easier. There’s no problem with having to use two different  
stimEnding vars, but the fact that using one produces unstable behavior is  
a big problem, from our perspective (per lab meeting discussion).

Evan

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 27, 2017, 2:10pm UTC](https://mworks.discourse.group/t/help-debugging/405/8 "2017-07-27T14:10:31Z")

</div>

> Let me see if I can rework things in the frame list stimulus so that the “ending” variable never gets set more than once.

This is done (for both “ending” and “ended”) and will be in the nightly build soon.

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 27, 2017, 2:20pm UTC](https://mworks.discourse.group/t/help-debugging/405/9 "2017-07-27T14:20:28Z")

</div>

Great, thanks!

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 19, 2022, 9:56pm UTC](https://mworks.discourse.group/t/help-debugging/405/10 "2022-07-19T21:56:26Z")

</div>


