# Ball Moving Jittered on Monitor

**URL:** <https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516>\
**Category:** Support\
**Created:** [June 18, 2015, 3:46pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516 "2015-06-18T15:46:23Z")\
**Posts on this page:** 13\
**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:** [June 18, 2015, 3:46pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/1 "2015-06-18T15:46:23Z")

</div>

Hi Chris,

I have a MWorks script that run smoothly on one computer (there is a ball moving on monitor with a certain speed). However, when I copy the same script to another computer, the ball moving trajectory becomes jittered (not smoothly moving) for 60% of the trials. I am not sure how and why it happens because it seems normal for 40% of the trials. Is it something related to monitor sampling frequency?

Thanks a lot,  
Chia-Jung

---

<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:** [June 18, 2015, 4:07pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/2 "2015-06-18T16:07:11Z")

</div>

Hi Chris,

I would like to supplement what the warning message from console. I am not sure why it would skip refresh cycles, because it does not have this issue while I run on another computer.

WARNING: Skipped 1 display refresh cycles  
01:33:36: WARNING: Skipped 2 display refresh cycles  
01:33:36: WARNING: Skipped 2 display refresh cycles  
01:33:36: WARNING: Skipped 2 display refresh cycles  
01:33:36: WARNING: Skipped 1 display refresh cycles

---

<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:** [June 18, 2015, 5:47pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/3 "2015-06-18T17:47:12Z")

</div>

Hi Chia-Jung,

There are a number of potential explanations for this issue. Can you give me some details about the two computers? Specifically:

- Model (Mac Pro, Mac mini, etc.)
- Graphics card
- Refresh rates of all attached displays

Thanks,  
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:** [June 18, 2015, 6:27pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/4 "2015-06-18T18:27:52Z")

</div>

Hi Chris,

The computer that runs successfully:  
OS X 10.9.5  
Processor 3.2 GHz Quad-Core Intel Xeon  
Memory 6 GB 1066 MHz DDR3 ECC  
Cinema HD Display 23-inch Late 2005 (1920 x 1200)  
Graphics ATI Radeon HD 5770 1024 MB  
Refresh rate: 60 Hz (based on #SYSTEM VARIABLES #mainScreenInfo ‘refresh\_rate\_hz’)

The computer that fails and has skipped refresh cycles:  
OS X 10.9.5  
Processor 2.93 GHz Intel Core 2 Duo  
Memory 4 GB 1067 MHz DDR3  
Built-in iMac Display 24-inch (1920 x 1200)  
Graphics ATI Radeon HD 4850 512 MB  
Refresh rate: 60 Hz (based on #SYSTEM VARIABLES #mainScreenInfo ‘refresh\_rate\_hz’)

---

<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:** [June 18, 2015, 6:56pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/5 "2015-06-18T18:56:43Z")

</div>

Hi Chia-Jung,

Thanks for the info. FYI, the `refresh_rate_hz` value doesn’t (currently) contain the actual refresh rate of the display. It comes from MWorks’ config file, and I believe it was originally intended to _set_ the refresh rate (although I don’t know if it ever did that). Regardless, I suspect both of your displays do in fact run at 60 Hz.

I’m guessing the problem here is simply that your iMac isn’t able to keep up with the display refreshes and is dropping frames. Are you using only the integrated display, or do you have an external display connected, too? Are you running both MWClient and MWServer on the iMac?

Thanks,  
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:** [June 19, 2015, 12:59am UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/6 "2015-06-19T00:59:51Z")

</div>

Hi Chris,

Thanks a lot. I am not sure how to know the **actual refresh rate** for the monitors.

The computer I ran successfully:  
I have an external display monitor connected to the computer. I ran both MWClient and MWServer on that computer, and the stimuli display is normal on the external display. I then connected to the Server from other computer to monitor the real-time activity.

The computer (iMac) that had issue:  
I firstly ran both MWClient and MWServer on iMac without external display. However, this would produce a blank fullscreen without any stimuli displayed. I have to press Cmd-Q to quit.

I then tried to connect iMac with an external display. The experiment could work, but then I started to see the jittering of the ball trajectory within 60% of the trials, and also saw the warning message on console.

I also tried to remove the external display, and connect iMac remotely. The experiment worked, and I did not see the serious jittering nor warning message on the console. However, the ball moves, it looks like it’s swimming in a wave. Not sure if it is an artifact of the refresh rate or not.

Thanks,  
Chia-Jung

---

<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:** [June 19, 2015, 3:01pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/7 "2015-06-19T15:01:03Z")

</div>

Hi Chia-Jung,

> I am not sure how to know the actual refresh rate for the monitors.

Yeah, it’s not always easy to find. For external monitors, usually you can find it in the “Displays” section of System Preferences. However, I don’t think that’s true for integrated displays.

> I then tried to connect iMac with an external display. The experiment could work, but then I started to see the jittering of the ball trajectory within 60% of the trials, and also saw the warning message on console.

It sounds like your iMac just isn’t up to the task of reliably driving two displays at 60 Hz. Given its hardware specs, this doesn’t surprise me.

> I also tried to remove the external display, and connect iMac remotely. The experiment worked, and I did not see the serious jittering nor warning message on the console.

Good, that’s also as I’d expect.

> However, the ball moves, it looks like it’s swimming in a wave. Not sure if it is an artifact of the refresh rate or not.

I don’t know what to make of that. Would it be possible for me to stop by your lab and see this in action?

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:** [June 19, 2015, 3:40pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/8 "2015-06-19T15:40:39Z")

</div>

Hi Chhris,

Thank you so much! Yes, it would be really helpful if you can stop by our lab and take a look at it.

Today before 2:30 pm, or between 3:30-4 pm would be available.  
Monday - Friday between 3:30 - 5 pm

Thanks a lot,  
Chia-Jung

---

<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:** [June 19, 2015, 6:07pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/9 "2015-06-19T18:07:28Z")

</div>

Hi Chris,

Thanks a lot for dropping by our lab today! I just attached the  
experimental file (.xml) along with two figure files (.jpg) and two sound  
files (.wav). The path for figure and sound might need to be changed from  
/Users/cjchang/MWorks/cjchang/ to a new path.

Thanks again,  
Chia-Jung

---

<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:** [June 19, 2015, 6:07pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/10 "2015-06-19T18:07:28Z")

</div>

Attachment: [Experiment.zip](https://mworks.discourse.group/uploads/short-url/phXVmmUdi7TETL9NuCm12lI8E7r.zip) (103 KB)

---

<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:** [June 25, 2015, 3:30pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/11 "2015-06-25T15:30:41Z")

</div>

Hi Chia-Jung,

Thanks for sharing your experiment. Regarding this:

> I also tried to remove the external display, and connect iMac remotely. The experiment worked, and I did not see the serious jittering nor warning message on the console. However, the ball moves, it looks like it’s swimming in a wave. Not sure if it is an artifact of the refresh rate or not.

After some investigation, I believe the “swimming in a wave” effect you’re seeing is due to a combination of display refresh rate and a “persistence of vision” effect.

To demonstrate this, I created a very simplified version of your experiment (attached), which simply plays the moving bar in an infinite loop. To emphasize the effect, I increased the speed of the bar to 128 degrees/second. At that speed, the bar “jumps” many times its own width each frame.

When I run this experiment on a display with a 60Hz refresh rate, I clearly see multiple bars displayed at once, in what looks like a “rolling” stripe pattern. However, when I put a photodiode in front of one of the bars and connect it to an oscilloscope, I can see that the pixels actually light up for only one frame (~16.67ms). This tells me that the striping I see is in fact an optical illusion. As you lower the speed of the bar, the effect becomes less dramatic, and the striping starts to look more like smearing.

So, in summary, it looks like the animation is working as it should, but your brain is tricking you in to thinking it’s not.

Cheers,  
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:** [June 25, 2015, 3:30pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/12 "2015-06-25T15:30:41Z")

</div>

Attachment: [infinite\_loop.xml](https://mworks.discourse.group/uploads/short-url/tVtY6n81QuqFyGWiUMLEQ5B8ywo.xml) (3.75 KB)

---

<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, 10:39pm UTC](https://mworks.discourse.group/t/ball-moving-jittered-on-monitor/516/13 "2022-07-19T22:39:51Z")

</div>


