Community
Participate
Working Groups
The "Organize Imports" command run on UI Thread and this lead to a possible long (> 1 minute) UI freeze for large project beeing indexed. This UI freeze occurs when Thread.sleep is called in JobManager.performConcurrentJob to wait "Java indexing" for completion. Maybe it's possible tu run "Organize Imports" command in "Worker-Thread" for not freezing UI.
Note that OrganizeImportsOperation is located in jdt.core.manipulation so the entire modification of the compilation unit can be done outside of UI code. After playing around with IProgressService.run(..), JavaCore.run(..) and various other things that didn't seem to have the desired effect, I settled on the Job API. I've attached a patch that seems to fix things. I added a 15s wait in OrganizeImportsOperation to simulate a long run. Note that you can navigate and even make other edits in the file while OrganizeImportsOperation runs. I think setting a scheduling rule should still be done so that attempting to save while the operation is running forces the progress bar to come out, indicating that another operation is in progress.
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/166361
Tested and ok for me. Thx !
(In reply to Roland Grunberg from comment #1) > Note that OrganizeImportsOperation is located in jdt.core.manipulation so > the entire modification of the compilation unit can be done outside of UI > code. > > After playing around with IProgressService.run(..), JavaCore.run(..) and > various other things that didn't seem to have the desired effect, I settled > on the Job API. I've attached a patch that seems to fix things. I added a > 15s wait in OrganizeImportsOperation to simulate a long run. Note that you > can navigate and even make other edits in the file while > OrganizeImportsOperation runs. Sounds good. > I think setting a scheduling rule should > still be done so that attempting to save while the operation is running > forces the progress bar to come out, indicating that another operation is in > progress. Yes. Andrey, can you please take a look and let us know if you see any potential issues?
(In reply to Noopur Gupta from comment #4) > Andrey, can you please take a look and let us know if you see any potential > issues? I've commented on review.
(In reply to Andrey Loskutov from comment #5) > I've commented on review. Thanks, Andrey.
Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/166361 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=66d9f2c91d01f6007953a3c37e6a43403c34445e
Verified for 4.17 M3 using I20200818-0900 build
Created attachment 284076 [details] Screenshot Roland, should that fix also work for the save action? I still get from time to time the Slow Save Actions popup due to organize imports, see screenshot in Eclipse SDK Version: 2020-12 (4.18) Build id: I20200904-0540 OS: Linux, v.5.4.0-45-generic, x86_64 / gtk 3.24.20, WebKit 2.28.4 Java version: 14