Skip to content

Commit 634105e

Browse files
rashedmytprabhakk-mw
authored andcommitted
Fixes hanging figure outputs in notebooks when the Desktop is opened and subsequently closed.
In MATLAB R2025a, figure outputs in notebooks may hang if the user switches to the Desktop and then closes the browser tab. This issue is resolved for MATLAB R2025b and later.
1 parent 057564d commit 634105e

File tree

1 file changed

+8
-1
lines changed
  • src/jupyter_matlab_kernel/matlab/+jupyter

1 file changed

+8
-1
lines changed

src/jupyter_matlab_kernel/matlab/+jupyter/execute.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
% of a unique Live Script. Hence, each execution request can be considered as
1313
% creating and running a new Live Script file.
1414

15-
% Copyright 2023-2024 The MathWorks, Inc.
15+
% Copyright 2023-2025 The MathWorks, Inc.
1616

1717
% Embed user MATLAB code in a try-catch block for MATLAB versions less than R2022b.
1818
% This is will disable inbuilt ErrorRecovery mechanism. Any exceptions created in
@@ -47,6 +47,13 @@
4747
hotlinksPreviousState = feature('hotlinks','off');
4848
hotlinksCleanupObj = onCleanup(@() feature('hotlinks', hotlinksPreviousState));
4949

50+
% Figures hang in MATLAB versions >= R2025a for certain workflows. The following
51+
% workaround fixes the issue in MATLAB versions >= R2025b.
52+
if ~isMATLABReleaseOlderThan("R2025b")
53+
forceIndependentlyHostedFiguresProp = addprop(groot, "ForceIndependentlyHostedFigures");
54+
propCleanupObj = onCleanup(@() delete(forceIndependentlyHostedFiguresProp));
55+
end
56+
5057
% Use the Live editor API for execution of MATLAB code and capturing the outputs
5158
resp = jsondecode(matlab.internal.editor.evaluateSynchronousRequest(request));
5259

0 commit comments

Comments
 (0)