When I connect/disconnect my external monitor, a Java exception appears on MATLAB's command line:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData at sun.java2d.xr.XRPMBlitLoops.cacheToTmpSurface(XRPMBlitLoops.java:148) at sun.java2d.xr.XrSwToPMBlit.Blit(XRPMBlitLoops.java:356) at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:959) at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:577) at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:67) at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014) at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:186) at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3318) at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3296) at javax.swing.ImageIcon.paintIcon(ImageIcon.java:425) at com.mathworks.toolstrip.plaf.GalleryButtonUI.paintContent(GalleryButtonUI.java:115) at com.mathworks.toolstrip.plaf.RegularButtonUI.paintContent(RegularButtonUI.java:64) at com.mathworks.toolstrip.plaf.ToolstripButtonUI.paint(ToolstripButtonUI.java:197) at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161) at javax.swing.JComponent.paintComponent(JComponent.java:780) at com.mathworks.mwswing.MJButton.paintComponent(MJButton.java:430) at javax.swing.JComponent.paint(JComponent.java:1056) at com.mathworks.mwswing.MJButton.paint(MJButton.java:408) at javax.swing.JComponent.paintChildren(JComponent.java:889) at javax.swing.JComponent.paint(JComponent.java:1065) at javax.swing.JComponent.paintChildren(JComponent.java:889) at javax.swing.JComponent.paint(JComponent.java:1065) at javax.swing.JComponent.paintChildren(JComponent.java:889) at javax.swing.JComponent.paint(JComponent.java:1065) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210) at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:290) at javax.swing.RepaintManager.paint(RepaintManager.java:1272) at javax.swing.JComponent._paintImmediately(JComponent.java:5158) at javax.swing.JComponent.paintImmediately(JComponent.java:4969) at javax.swing.RepaintManager$4.run(RepaintManager.java:831) at javax.swing.RepaintManager$4.run(RepaintManager.java:814) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789) at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738) at javax.swing.RepaintManager.access$1200(RepaintManager.java:64) at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
I'm using MATLAB R2017b (fresh install) on Xubuntu 17.10. I'm invoking MATLAB via the command
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/local/MATLAB/R2017b/bin/matlab -desktop
Since this doesn't crash the MATLAB GUI, I don't consider it a critical issue, but it is annoying (and easily reproduced).
Edit: Arguably this does 'crash' the MATLAB GUI: subsequent keyboard input retriggers the same exception. My workaround, which I forgot to mention, is mouse-clicking the Clear Workspace button. I won't pretend to understand how this resolves the issue.

10 Kommentare

Charles
Charles am 12 Jan. 2018
Call this a "me too".
The issue is triggered with a monitor reconfiguration. I do consider this critical, because after every command on the command line, it spits out all same the red error messages again.
Fresh install of R2017b, running under Linux Mint 18.3, Mate desktop.
Nick Knight
Nick Knight am 12 Jan. 2018
I also observe this behavior, but when I click the "Clear Workspace" button, the red error messages cease. Sometimes, but not always, changing the directory by clicking on the address bar fixes it too.
I forgot to mention the "Clear Workspace" workaround in my original post --- without it I would indeed consider this to be critical.
kowshik Thopalli
kowshik Thopalli am 17 Jan. 2018
Bearbeitet: kowshik Thopalli am 17 Jan. 2018
I have the same issue too. R 2017b under ubuntu 16.04 LTS. message ceased after pressing "clear workspace" button
Andrew King
Andrew King am 17 Apr. 2018
Same issue here with R2018a in Ubuntu 16.04. Clearing the workspace makes the command window look fine, but figures remain frozen. This is a critical issue for me.
Nick Knight
Nick Knight am 17 Apr. 2018
I just upgraded to R2018a: the issue persists. I then tried switching from Xubuntu to Ubuntu (both 17.10): the issue persists.
I'm now noticing GUI glitches even after invoking the "Clear Workspace" workaround. For example, if you unplug the external monitor while the Editor's "quick-help" context menu is open, then the context menu remains stuck open, even after the Editor is closed.
Richard Crozier
Richard Crozier am 27 Jul. 2018
Same issue, R2018a Mint Linux 17.3
Nathan Ullberg
Nathan Ullberg am 12 Okt. 2018
Similar issue for me: R2018b, Ubuntu 18.04.
Richard Crozier
Richard Crozier am 18 Okt. 2018
R2018b Ubuntu 18.04, also still get same issue
Jo Williams
Jo Williams am 13 Feb. 2020
...Same here. I'm operating through NX, and it seems to be when the NX window is resized that matlab triggers all this.
MATLAB Version: 9.5.0.944444 (R2018b)
Operating System: Linux 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64
Java Version: Java 1.8.0_152-b16 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Onur
Onur am 19 Dez. 2022
This started happening to me after I switched between json files and matlab scripts and never before that.
Perhaps there is something in json which triggers this bug in R2017b. I also noticed a little box on the bottom left titled "(JSON File)" with the label "No details available" in it.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Andrew King
Andrew King am 17 Apr. 2018

8 Stimmen

Seems like I've fixed my problem by disabling xrender by putting the line

-Dsun.java2d.xrender=false

in a new file called /usr/local/MATLAB/R2018a/bin/glnxa64/java.opts

Unintended consequences TBD.

Java options ref: https://www.mathworks.com/help/matlab/matlab_env/java-opts-file.html?s_tid=srchtitle

Similar bug: https://www.mathworks.com/matlabcentral/answers/381324-why-do-i-get-java-exception-on-display-change

3 Kommentare

Nick Knight
Nick Knight am 18 Apr. 2018
I am accepting this answer as it appears to have resolved my issue, at least for R2018a on Ubuntu 17.10, and the only risk seems to be a possible performance hit: sun.java2d.xrender: [...] enable the XRender-based Java 2D rendering pipeline for modern X11-based desktops, offering improved graphics performance
Guillaume R
Guillaume R am 13 Nov. 2018
I tried that solution on Ubuntu 18.04 and with Matlab R2018b. I don't know if it solved it, but it made the graphics performance so low and laggy that it was unusable, so I removed it. Would be nice to have an official fix provided by Mathworks.
Emanuel Mahina
Emanuel Mahina am 10 Apr. 2020
How to do,on the terminal?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Robert
Robert am 13 Nov. 2018

0 Stimmen

I had the same issue with R2018a on Xubuntu 16.04 and 18.04 operated remotely via X2Go. Thanks for the solution, works fine! This answer should definitely be placed more prominently, e.g. in the FAQ. Took me a while to find it..

Kategorien

Mehr zu Environment and Settings finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Gefragt:

am 20 Dez. 2017

Kommentiert:

am 19 Dez. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by