timer misbehaving in GUI after upgrade to 2017b?
8 views (last 30 days)
Show older comments
Chris McGibbon
on 26 Feb 2018
Commented: Cam Salzberger
on 27 Feb 2018
Many years ago I wrote some GUIs for animating 3D marker data from motion capture. I was using 2009b at the time and I know the guis worked fine in 2010b. I recently tried to run one of them with 2017b, but the timer is not behaving correctly. It started to play, but seemed choppy and would not respond immediately to button commands after the timer was started. The more I tested it, and tested other GUIs that use the same code for setting and controlling the timer, the worse it seemed to get, to the point the timer would completely hang up. All my guis using the same timer code seem to be affected.
If I run a simple timer from the command window it works fine, so I'm perplexed.
Because no error is generated I'm not even sure where to look to try to solve this problem.
Is there something about Matlab2017b timer control behavior in a GUI (built with GUIDE) that would be different from older (2009b) versions?
Not sure it is important, but the 'TimerFcn' callback code has a global variable "frm" (index frame) for displaying the current position of markers that is also updated. This has never been a problem and I don't think it is causing this, but otherwise I'm not sure how else to pass an index to the TimerFcn.
1 Comment
Jan
on 26 Feb 2018
Without seeing the code it is hard to guess, where the problem is.
Using the same timer code for several GUIs with the same global variable is a bad idea, but it should not produce the observed behavior. But what do you observe exactly? "seemed choppy and would not respond immediately to button commands after the timer was started" is not really clear. What is a "button command"?
Accepted Answer
Cam Salzberger
on 26 Feb 2018
Hello Chris,
The biggest (relevant to you) change that has happened in that time is a complete change to the graphics engine in R2014b. This has had a large impact on GUIs in general, and especially on GUIs developed before that release and being used in a later release. I suspect that the timer isn't the issue, but instead the graphics input or updates causing the slow down.
Can you divorce the old timer code from the GUI, and use it with some text-only function to eliminate the GUI from the equation? If it works fine, then I suspect the GUI has some issues from the compatibility or inefficiencies due to the new graphics engine.
I'd highly suggest checking out the "Additional Resources" at the bottom of the new graphics engine page to get some suggestions for optimizing graphics operations.
-Cam
4 Comments
Cam Salzberger
on 27 Feb 2018
No problem. I'm glad I was able to help at least a bit. Using drawnow makes sense if you want to see the graphics updates immediately, but there is a lot of other code running as well. Typically this is an issue when updating graphics in a loop, not from a timer callback, but it's reasonable that it could happen then too. Sorry for not thinking to suggest that before.
One thing to make sure of is that you aren't clearing the axes at any point in this animation cycle. I didn't see anything like that in your code, but maybe it's somewhere else. The flickering could also be caused by the axes limits changing every time the line data is changed. If you know that the data will always be within a reasonable range, you could set the limits manually, and ensure that 'XLimMode', 'YLimMode', and 'ZLimMode' are 'manual' to avoid limits changing.
-Cam
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!