MATLAB Answers

App Designer updates much (20x) slower than GUIDE

105 views (last 30 days)
Bramvg on 5 Mar 2020
Edited: Torsten Knüppel on 23 Apr 2020
With App Designer I made an application that gets an image from a camera and after some processing displays it in a GUI. The problem is that it is extremely slow. It turns out this is due to the slow updating in the uifigure (using drawnow).
Below is a simple script to reproduce the problem. The script plots an image and a button, which calls a function that updates the image. The script does the same thing twice, once using uifigure (App Designer) and once using figure (GUIDE).
close all hidden
%% app designer example
figure1 = uifigure('Name','UIFigure 1');
figure1.Position = [100 100 500 400];
axes1 = uiaxes(figure1);
axes1.Position = [50 50 400 300];
im1 = imagesc(axes1,rand([1280 1024]));
button1 = uibutton(figure1,'push');
button1.Position = [20 370 150 22];
button1.Text = 'push to refresh!';
button1.ButtonPushedFcn = {@buttonpushed,im1};
%% guide example
figure2 = figure(2);
figure2.MenuBar = 'none';
figure2.Position = [700 100 500 400];
axes2 = axes(figure2,'Units','pixels');
axes2.Position = [50 50 400 300];
im2 = imagesc(axes2,rand([1280 1024]));
button2 = uicontrol(figure2,'Style','pushbutton');
button2.Position = [20 370 150 22];
button2.String = 'push to refresh!';
button2.Callback = {@buttonpushed,im2};
%% callback function
function buttonpushed(~,~,h)
im = rand([1280 1024]);
h.CData = im;
The timing results from tic/toc in the callback function, for my computer and Matlab R2018b are:
  • For UIFigure 1: Elapsed time is 0.872563 seconds.
  • For Figure 2: Elapsed time is 0.042053 seconds.
(These timings are reproducible.) This is a factor 20 difference! And this means the difference between a snappy and an extremely sluggish GUI. The same performance difference is visible while loading the script.
Is this normal behavior or am I doing something wrong?


Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 5 Mar 2020
Try calling
drawnow limitrate
instead of
with no inputs.


Bramvg on 5 Mar 2020
Adding 'limitrate' indeed makes the tic/toc faster, figure and uifigure now have comparable timings (~0.03 s). However, looking at the screen the actual updating still takes ~1 s for the UIFigure, while the Figure updates almost instantly.
It seems that limitrate does not really speed up the drawing, it only makes it asynchronous. It does help a little bit in my application, since the image processing of the next frame can start a little earlier. But I still cannot get a snappy GUI, with response times close to 1 s.
Question remains why there is such a huge performance difference between UIFigure and Figure.
Torsten Knüppel
Torsten Knüppel on 23 Apr 2020
It contains some recent entries suggesting that the performance is improved in the more recent releases. I'm using 2018a (probably pretty similiar to your 2018b) and it seems that the implementation of this entire app designer thing in these releases is not more than an unusable beta version.

Sign in to comment.




Translated by