extremely bad performance of event issuing by slider uicontrol in version R2020b

1 view (last 30 days)
I have observed that in the new version of Matlab, the slider uicontrol does not issue events properly when used continuously. The value of the slider does not change as the user moves the slider.
I attach a function that illustrates this behaviour.
function sliderPerformance
function sliderPerformance
nfig = figure();
x = linspace(0,2*pi,10000);
hplot = plot(x,cos(0*x),'LineWidth',2);
ylim([-2,2]);
h = uicontrol('style','slider','units','pixel','position',[20 20 300 20],'Parent',nfig);
% checks continuosly the update of the value in the slider
addlistener(h,'Value','PostSet',@(hObject, event) updatePlot(hObject, event,x,hplot));
function updatePlot(src,event,x,hplot)
persistent lastVisit
if isempty(lastVisit);
lastVisit = clock();
return
else
thisVisit = clock();
end
fprintf('Time since last event: %5.2f s\n',etime(thisVisit,lastVisit));
hSlider = event.AffectedObject;
n = hSlider.Value;
hplot.YData=cos(x*n);
ylim([-2,2]);
drawnow;
lastVisit = thisVisit;
When operated from any version previous to R2020b, the plot transitions smoothly as the user moves the slider, and (a sample of) the readout to the screen is:
Time since last event: 0.01 s
Time since last event: 0.11 s
Time since last event: 0.06 s
In R2020b, the plot transition is bumpy, and, accordingly the readout:
Time since last event: 0.08 s
Time since last event: 0.47 s
Time since last event: 1.11 s
Time since last event: 2.25 s
Time since last event: 4.51 s
Time since last event: 3.46 s
Time since last event: 4.65 s
Is something that can be done? Is this reportable as a bug?

Answers (1)

Cris LaPierre
Cris LaPierre on 11 Dec 2020
Your code runs smoothly for me in 20b and 21a prerelease.
Times are
  • Time since last event: 0.04 s
  • Time since last event: 0.04 s
  • Time since last event: 0.04 s
  • Time since last event: 0.03 s
  • Time since last event: 0.04 s
  • Time since last event: 0.04 s
  • Time since last event: 0.04 s
  • Time since last event: 0.05 s
  • Time since last event: 0.05 s
  • Time since last event: 0.04 s
  • Time since last event: 0.03 s
  • Time since last event: 0.03 s
  • Time since last event: 0.04 s
  • Time since last event: 0.03 s
  • Time since last event: 0.04 s
  • Time since last event: 0.04 s
  • Time since last event: 0.04 s
  • Time since last event: 0.04 s
  • Time since last event: 0.04 s
  8 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by