JDK-8262882 : Lanai: NetBeans crashes often when switching between dual and single screen
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: internal
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-03-02
  • Updated: 2021-03-09
  • Resolved: 2021-03-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
internalFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
This was uncovered when testing the latest lanai repo, up to this commit:

https://github.com/openjdk/lanai/commit/478286d5470bf7bb933f87d5842c42eb16252dd8

and including the fixes for JDK-8262750, JDK-8262729, and JDK-8262496.

I reproduced this as follows:

1. Enable the discrete graphics card (so there would be no graphics card switch, although it doesn't matter to this bug)
2. Run NetBeans without metal API validation
3. Plug in external monitor
4. Unplug external monitor
5. Repeat steps 3-4 until it crashes
Comments
[~kcr] Thanks for the confirmation.
05-03-2021

The patch you sent me to comment out the call to MTLGC_DestroyMTLGraphicsConfig avoids the crash. I ran several times using a build with that call commented out, and it runs fine. I then did a local build reverting your temporary patch, thus restoring the call to MTLGC_DestroyMTLGraphicsConfig (and no other changes) and it crashes easily.
04-03-2021

There is an indication in debug logs that the crash is in cleaning up MTLContext. [I] MTLGC_DestroyMTLGraphicsConfig [I] MTLContext.dealloc Not sure why are we not hitting this point without the scenario that [~kcr] has mentioned. Inability to reproduce this issue is hampering any intermediate fix testing. It is not a favored option, but a quick fix would be to allow old MTLContext object to leak - and fix the leak separately later on.
04-03-2021

It still happens with the latest changes (a local build that includes the fix for JDK-8262936). When it does crash, it is more often when I unplug the monitor -- so going from dual to single screen -- although I just got a crash from SwingSet2 going from single to dual. To Ajit's point, it does seem likely that it is related to using the discrete graphics card.
03-03-2021

This is not reproducible in my 13inch Macbook pro also. Performed continuous text/tree scrolling while plugging/unplugging multiple times. Recently we had fix for similar plug/unplug scenario under JDK-8262750 in integrated SoC. Today i did follow up code verification task under JDK-8262928 and added commandbuffer flush logic for setSurfaces also which was missing. [~kcr] Please verify if there is any change in reproducibility of this issue in latest code.
03-03-2021

I cannot connect my macBook pro 16" to external monitor as the USB-C to HDMI adapter that I have ordered has not yet arrived. I think, this bug is peculiar to discrete graphics card. I tried the same steps with macBook pro 13" that has only integrated graphics card. Netbeans never crashed with multiple plug-in/plug-out of external monitor.
03-03-2021

We need to be a bit careful with the "regression" label. It has been removed from this bug already but if it were still there and we decided this was serious but a corner case and integrated into JDK, then what would "regression" mean ? It certainly would not be a JDK 17 regression w.r.t JDK 16 or earlier ...
03-03-2021

More information: I tried this with EA 9 and was able to make it crash there, too. I suspect I had not done this level of stress testing before. It crashes most easily when I am scrolling text with the trackpad while plugging or unplugging the external monitor. I think the priority can be lowered since it is definitely not a recent regression -- and likely not a regression at all.
02-03-2021

With EA 9, or with the latest build, I can make it happen with SwingSet2 as well. Very odd, since I'm reasonably certain that was tested.
02-03-2021

I backed out the last three changes and it still crashes, so this might not be a recent regression.
02-03-2021

I filed this as P1, since it is a serious regression. I'll try to narrow down the fix that caused the regression.
02-03-2021