eirikbakke opened a new pull request, #7668:
URL: https://github.com/apache/netbeans/pull/7668

   Some improvements to the NbClipboard class, in three separate commits:
   1) Adjust the retry logic from https://github.com/apache/netbeans/pull/6443 
by applying an exponential backoff on the delays. I saw a large number of 
retries in the log on various occasions, as well as a case where Microsoft 
Excel complained about not being able to access the clipboard because NetBeans 
was hogging it (error message screenshot below).
   
   
![image](https://github.com/user-attachments/assets/d2635970-1275-4eaf-a912-6288ffa03976)
   
   (This commit I have been using in my working IDE and platform app since 
January 2024.)
   
   2) Avoid blocking the Event Dispatch Thread during calls to 
systemClipboard.addFlavorListener()/removeFlavorListener(). This can happen 
because these methods are synchronized on the same object as the expensive 
systemClipboard.getContents() method. I once saw NetBeans Platform app hang for 
a long time in removeFlavorListener(), and tracked it down (with the VirtualVM 
profiler) to attempting to acquire the same lock as getContents(). The hang 
itself was caused by a different misbehaving application (Oracle VirtualBox), 
but I can imagine other cases where a more normal situation can also cause a 
multi-second hang.
   
   Event dispatch thread (AWT-EventQueue):
   <img width="623" alt="image" 
src="https://github.com/user-attachments/assets/dbbe92bf-624d-4cf3-893d-0f20fd163352";>
   Clipboard synchronizer thread concurrently holding the lock:
   <img width="391" alt="image" 
src="https://github.com/user-attachments/assets/c2dd23eb-eeb5-45b8-af40-d414d222f820";>
   
   (This commit I have been using in my working IDE on Windows for only 5 days, 
but I haven't seen any problems with it so far. I'll be switching to a new 
MacBook laptop now, so my Windows setup won't see too much organic usage after 
this.)
   
   3) Get rid of some dead code, after reviewing the historical commit from 
2012 that left it unused. See the description of the third commit in this PR.
   
   There are some long-standing [intermittent 
bugs](https://github.com/apache/netbeans/issues/3962) with Cut and Paste on 
Windows, which are either caused by, or have to be fixed with, changes in the 
NbClipboard class. The changes above were not specifically made to fix those 
bugs, but improving the code is probably a good thing in any case.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to