Problems with copy and paste in windows · Issue #3962 · apache/netbeans · GitHub
source link: https://github.com/apache/netbeans/issues/3962
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Problems with copy and paste in windows #3962
andersonneto opened this issue Apr 11, 2022 · 89 comments
Comments
Apache NetBeans versionApache NetBeans 13 What happenedThis issue has been occurring in this version and earlier. Sometimes when we copy text from a website/browser on Windows operating system, Netbeans pastes information that was copied into Netbeans itself. And many times, I select from the website and drag it to Netbeans, to paste the text. How to reproduceThe problem is only solved when I restart the application. Did this work correctly in an earlier version?Operating SystemWindows 16.0.2 (64bit) Apache NetBeans packagingApache NetBeans binary zip Anything elseNo response Are you willing to submit a pull request?Code of Conduct |
added kind:bug Bug report or fix needs:triage Requires attention from one of the committers
labels
removed the needs:triage Requires attention from one of the committers label
Unfortunately a long standing annoyance, which doesn't seem to have a definitive reproducible cause, or we know whether it's definitely NetBeans or the JDK at fault. Have a read of https://lists.apache.org/thread/xqkwy4wxylmzprxl1wko301hlqz59r7d and some of the flags, logging settings, etc. Be great to get to the bottom of this one! |
This is very annoying problem. I teach coding. Usually I code in a Google doc because it is live and students can follow along easily. When I want to compile my code I paste it into NetBeans. It fails and only pastes the last thing I copied from within Netbeans. Apparently the copy and paste works only within Netbeans. THIS IS A PROBLEM. Please fix! The work around is to open the source file concurrently in a text editor and copy and paste there which updates the source file in Netbeans. |
@Montanajim if you have a reliable reproducer, then please share as much information as you can about environment, JDK, Windows version, browser you're pasting from, etc. Does it reproduce immediately, or after a time? Is it after a particular type of content has been added to the clipboard (from anywhere)? Do any of the suggestions in the linked thread above help? Is it NetBeans specific, or can you reproduce with other Java (Swing) applications? It's well known that this is a problem, just not what the fix should actually be! |
I can reproduce the bug through these steps:
I tested these steps with Notpad++, Firefox and the windows file explorer and have the same result exactly after these steps. Also if I mix applications in between. If I can send you any log files or if I can help somehow please write me. |
This happens also in Windows 11 with AdoptOpenJDK 11 and Netbean zip distribution |
Contributor
I have the same Problem. It occurs with any Apache Netbeans version (ranging from NB9 to NB15) and with every JDK Build on Windows that I have tested. This includes Java 8, 11 and 17 via Eclipse Temurin JDK, Azul Zulu JDK and some other JDK builds. The bug occurs seemingly random. Edit: Please see @epliskin's workaround as it also works consistently and does not require the extra plug-in from NB 7.1 I have found a workaround that works consistently: Setup
WorkaroundWhen the bug occurs, then press Alt+V in NB editor to open the clipboard history and insert any item from the menu that should have been opened by the plugin. Press Ctrl+Z to revert the insertion. The clipboard should work normally now. Performing the Workaround before the bug occurs does not stop the bug from happening. Only performing the workaround after the bug occurs fixes the problem until the bug occurs again. |
Same issue with NB 13 and JDK 17. Doing a Control + c in netbeans and then control + v in netbeans works but control + v in another application doesn't work. In the other application stuff that was copied earlier is pasted (not the stuff that was copied most recently from NB). Reverse doesn't work either. Doing empty Control+C (i.e. cntrl c without selecting any text) seems to reset this behavior. So, if ctrl v is not pasting the right stuff, do an empty ctrl c in netbeans and then select stuff and cntrl c to copy it. Now do ctrl v on another application to paste. It works. Once it is pasted, then the problem resurfaces. So you have to do an empty cntrl c again to reset. Crazy. |
Same issue with NB12 and NB13 platform applications using JDK 11, 16, 17. |
I have the same problem. the workaround by @duoduobingbing did not work the Copy and Paste History. The link is dead. anyone have a workaround too ? |
Contributor
A naive attempt to fix: #4572 Also you may add the following command line option to
That'd switch off NetBeans Clipboard handling hacks which is enabled by default on all platforms save Mac. Those hacks were introduced as a workaround for an AWT System clipboard issue around Java 5. They might be obsolete and causing issues now. Please report back your experience either you are trying a build with the PR or testing the app with the provided flag! |
Testing the command line option with Netbeans 14 on Windows 11 and Java 11 |
Member
Thanks @NicolaIsotta Could you also try with When you say it persists, is it immediate, or does it happen after some time? If after a time, is there anything you're doing that seems to be a common trigger? Is there anything that seems relevant in |
Contributor
Are you able to get a log of when it goes south. There discussion of this in https://lists.apache.org/thread/nsg2pdzrs3go9f4zlhy0gjs2hfxmbdbn But basically
|
Contributor
Also check with Java 17. This issue is on how Native Clipboard communicate with the JVM, so the JVM can count as well. |
Same issue with NetBeans 15, JDK 17, Windows. Based on duoduobingbing advice above the workaround is simply to open the built-in NetBeans clipboard history dialog with (Ctrl+Shift+D), select an item from history to paste into NetBeans editor and revert insertion with (Ctrl+Z). This magic revitalizes the NetBeans clipboard. |
Contributor
It is so strange that we do not get feedback from the Windows folk running the IDE with |
Besides, using the clipboard history, as mentioned by @epliskin , also works for me. |
An hour ago I configured netbeans.conf with (-J-DTopSecurityManager.disable=true -J-Dorg.netbeans.NbClipboard.level=FINEST) and started NetBeans 15 with JDK 17. Clipboard works as yet fine between NetBeans and other Windows programs. At this time I do not edit any code eagerly but will report here in coming days or weeks if and when NetBeans clipboard freezes again... |
Contributor
I wanted to thoroughly test before writing that this and that option definetely works or does not work; but here are my results after running with some options for a longer time:
|
See attached NetBeans log for this bug. I was editing some code when it happened. Could not paste from other Windows app, could not copy from NetBeans to another Windows app, but still could copy and paste text inside NetBeans editor. netbeans_default_options = ... -J-DTopSecurityManager.disable=true -J-Dorg.netbeans.NbClipboard.level=FINEST |
And again some time after NetBeans restart... |
I have the same problem with Netbeans 16, JDK 18. I have experienced the problem only in Java files so far, when I copy a text from |
Yes. i confirm. it works. |
Adding |
Member
added Contribution welcome An issue or feature not currently being worked on, but a contribution would be welcomed! label in case someone on windows wants to look into it. |
I whipped this together quickly. It reproduces the issue every time for me on a vanilla netbeans 18 install with JDK17. Here's an example/screen recording. It works on the first copy/paste attempt, and the subsequent 4 fail: Not sure exactly how you want me to contribute this, so just putting it here for now
|
@bradvido Super. Now we getting somewhere. |
@bradvido Brad, thanks for all the time you invested digging into this. This bug is a real PITA. Hopefully this really helps drilling down to the root cause. |
Thanks @bradvido for taking the time to write that code and share that video. Really useful to have. The negative is that I still cannot reproduce on my Windows 11 system. Tried increasing the I was using the community installer from https://www.codelerity.com/netbeans/ Can you replicate with that? That uses a bundled Azul JDK 20. Let's take JDK differences out of the equation. Secondly, could you share the output of Of course, my experience could be system dependent - the fact that having logging enabled fixes it for some people suggests that it could be a side effect of the code in the logging or a race condition somewhere. |
just a simple "run" of @bradvido 's code releases the freak from the first run here, jdk17, NetBeans 17, windows 10. It copies and pastes in editor from notepad and vice versa, every run produces different results, so it is not consistent for 5 iterations plus one run after the other. |
@istinnstudio thanks for confirming you are able to reproduce this with the code @neilcsmith-net , I've downloaded the installer from the codelerity link, and have tested that.
And still get the same results. Copy/Paste fails after one or two attempts. Interestingly, it's not consistent as to what attempt it start to fail on, but it always fails. Since we are on identical netbeans runtimes and JDKs, and you are saying that it's working consistently for you through 25 iterations, I'm at a loss. We are also both running Windows 11, Have you set and of these properties in your netbeans? Mine is completely vanilla.
|
@bradvido thanks for the info. Yes, vanilla settings. Only difference I can see is the locale |
I wouldn't think there would be, but is there a difference between using the zipped version of NetBeans vs the Windows installer? Is this a Windows only issue? Could the installer be setting up a different configuration? I download straight from Apache: https://netbeans.apache.org/download/nb18 Within the netbeans.conf file:
I've been doing that since probably NetBeans 15 and haven't had the copy/paste issue since. Now I do have another copy/paste issue in which NetBeans doesn't grab the correct text within the output dialog. I'm unsure if it is related. When I attempt to copy say "FGH" from "ABCDEFGHI" I may get "DEF" instead. This only happens in the output dialog though. I usually have the output dialog window text wrapped too. |
There are two possible installers, that set things up in slightly different ways. That was the other reason for asking for verification with the community installer, which uses NBPackage. The ASF installer hasn't moved to that yet. If it affected one and not the other it could have helped narrow things down. When you use the zip, which launcher do you use? That's unlikely to be the reason, though - the logging has side effects which I think may be helping some people.
This is #5293 by the sound of it. |
netbeans64.exe |
Contributor
Can't reproduce it with the
|
This comment was marked as off-topic.
I've done some A/B testing with and without having these properties set: With both set: fails on average at the 9th attempt. Based on this, it's the introduction of FINEST level logging that helps, but doesn't fix the issue. I have no idea why. One theory I have is that the extra logging introduces just enough of a slowdown in netbeans clipboard that allows {some other asynchronous process} to do its thing. Based on testing results, I don't think -J- I'm willing to dig in further but need some direction. |
@bradvido for my first tests I made a basic platform application via maven and debuged it. I got the feeling that in this app the error occured much less frequently. So I guess it is somewhere in additional flavours code, maybe in copy Java flavour since some of the hacks to resolve it using copy class stuff. |
just a short video to show how easy is to reproduce with @bradvido 's code, just place the cursor in an empty line position and run... and the screenshot of the second run: |
@bradvido It could be that, but it could also be that the logging introduces a bunch of potential side effects - or at least eagerly initializes some things. See eg. https://github.com/apache/netbeans/blob/master/platform/o.n.bootstrap/src/org/netbeans/NbClipboard.java#L216 and As it still fails for you with logging enabled could you share anything relevant / different in the log output when you have a working vs non-working copy-paste? @istinnstudio yes, it's great to have something that easily reproduces on an affected system, but also more clearly shows that not all systems are affected. |
can someone post a netbeans.conf file of an unaffected system? just to be sure the default is identical. is there a way to enable logging in the release version or it is possible only in code while compiling? |
Well, mine is unaffected, with the default. I'm not sure how many people who are neither affected nor NetBeans developers are going to be tracking this issue!
Yes, adding |
Contributor
If you want to dynamically adjust the logging, without restarting NetBeans, there's I've wondered if turning the logging on/off without restarting NetBeans, might have different results. |
Here is the log output of a successful paste from netbeans to notepad and a failed paste from netbeans to notepad (with -J-Dorg.netbeans.NbClipboard.level=FINEST set) |
Today I could observe that a copy paste from a Java editor of an complete expr did fail and an incomplete expression worked again. Multiple times. Did anybody test this while java ide features are switched off? Maybe that is the reason my platform application did not have this problem anymore after including this logging fix. |
there is progress, at least for me! I do not know what exactly happened but having the "-J-Dorg.netbeans.NbClipboard.level=FINEST" at the end of netbeans.conf options (at the netbeans_default_options="... ") did nothing at all, Then I removed it. After reading last comments I have installed jLogMan and modified the shortcut in windows to point at --> "C:\Program Files\NetBeans-17\netbeans\bin\netbeans64.exe" -J-Dorg.netbeans.NbClipboard.level=FINEST, and then revelation, tested for 25 iterations with @bradvido 's code. Tested also real copy/paste sessions, fine, creasy stuff... so I do not know if the order of the argument plays a role (I guess it does) or the plugin has participated in this. |
Member
flag order shouldn't matter unless you configure logging twice. One thing to watch out for is that the config contains by default |
@mbien you are probably right. Maybe other arguments proposed here can "kill" the FINEST argument. At least it works as a shortcut or if used "standalone" after IgnoreUnrecognizedVMOptions. My new tests with many iterations revealed only one missed hit per try, but now it is rare maybe once per a big number like 256. So it does not resolve the issue completely, but changes the frequency it appears. I encourage users to use also the shortcut version and keep config to default. On tests with 256 iterations (reducing the sleep timings), if argument activated ok (checking the log), the FINEST reduces the frequency of the bug appearance. I got a missed hit at a random iteration, one at 14th on first try and one at 26th on the second. At least I can work now without much trouble. Hopefully this will work for others also till the final solution. Thanks everyone for their contribution, |
I tried this setup, but found no difference in specifying the option directly as an argument vs. adding it to the .conf file. Both enabled the extra logging in the log file. Both fail at the same rate (usually around the 7th copy/paste attempt). I also added the jLogMan plugin, hoping it may actually be causing your successes, but there was no change with it either. I was able to use it to confirm that the log level was set to FINEST for NbClipboard, but we already knew that. @istinnstudio , I will be interested to hear if this fix works for you long term, or if you just happened to get lucky. Keep us posted!
@neilcsmith-net this seems plausible, but I haven't found any smoking guns from just looking at the code. Also FYI, I did post logs of success vs failure here: #3962 (comment) |
Contributor
When the log level is FINEST and it's working better (which is mostly what people see), if you change it to inherit (which I'm assuming is default) without restarting, does it get worse? I'm assuming it will get worse; based on the current theory that code when FINEST changes something and makes things better. |
@errael I confirm that without restarting, using LogMan with inherit fails immediately with 5 fails / 12 iterations, FINEST is 1 or 2 fails per hundred's of iterations, now I got 2 fails/128 iterations, random positions at 97 and 124. |
in any case I paste the clean config and commented out the relevant arguments (not to be uncommented there, just for reference):
|
Contributor
Is it possible to reproduce the problem using a normal logging level and then using LogMan to increase the clipboard logging to FINNEST and setting what NetBeans thinks it is copying and pasting? I am not running NetBeans anymore but it stands to reason you could add enough logs to track the flow on success vs failure and diff the two. If you don't see ac difference, it means you need to add more logs until you catch the difference. |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
No one assigned
None yet
No milestone
No branches or pull requests
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK