Bug 546828 - Editors based on FileDocumentProvider / TextFileDocumentProvider lock UI on attempt to edit while build is running
Summary: Editors based on FileDocumentProvider / TextFileDocumentProvider lock UI on a...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.8.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.12 M3   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-29 10:45 EDT by Andrey Loskutov CLA
Modified: 2021-11-29 02:58 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2019-04-29 10:45:33 EDT
Subset of issues with bug 329657.

Open Xtext based editor.
Run a build job that works longer.
Try to type inside the Xtext editor - UI will lock immediately and will stay locked / frozen as long as workspace is locked by the build job.

Ideally there should be shown a "progress" dialog with the possibility to cancel current task (it is ValidateStateOperation from AbstractDocumentProvider which tries to run a workspace task with *null* rule).

The null rule is exact where the problem is. Because there is "no rule", jobManager.beginRule(null, monitor); will NOT show any progress dialog and the code in WorkManager.checkIn(ISchedulingRule, IProgressMonitor) will immediately try to acquire the lock which is already acquired by the build job.

Supplying the current file as rule is enough to get the dialog and also the possibility to cancel editing.

Right now the current state causes UI lockouts in our IDE where a build job can take not just few seconds but some hours, and this is effectively killing IDE UI...

I plan to provide a patch.
Comment 2 Eclipse Genie CLA 2019-04-30 11:31:41 EDT
New Gerrit change created: https://git.eclipse.org/r/141412
Comment 3 Andrey Loskutov CLA 2019-05-02 05:08:08 EDT
Just found that almost identical code exists in TextFileDocumentProvider, and that one don't need XText to lock out UI on trying to edit a file while build is running.

Same as comment 0 works also with Java default editor. I will update the patch to fix that one too.
Comment 4 Andrey Loskutov CLA 2019-05-02 05:10:16 EDT
To reproduce it in the IDE, create breakpoint in org.eclipse.core.internal.events.BuildManager.basicBuildLoop(IBuildConfiguration[], IBuildConfiguration[], int, MultiStatus, IProgressMonitor), run build, let the build thread stop at the breakpoint and try to play with editors.
Comment 6 Andrey Loskutov CLA 2019-05-03 11:43:00 EDT
Verified with I20190502-1800.
Comment 7 Bogdan Oprea CLA 2021-11-19 06:54:24 EST
Hi Andrey,

I used to work on Eclipse 4.11 and recently got to Eclipse 4.19 and 4.21.
I came across an issue.
If during a build (which can take more than a minute) I am editing a file which was not edited before build, a progress monitor appears and typing is not allowed until the build is done.
Previously we didn't have this issue.

I tried to track the issue and this led me to this bug.
I understand the motivation of this bugfix, however I tried to reproduce it on Eclipse 4.11 and I wasn't able to.

I tried during a 1 minute build to type in .txt file, .java file and also with the Xtext editor. None of them resulted in a GUI freeze.
Could you please let me know what am I doing wrong? How can I reproduce this bug in Eclipse 4.11?

Thanks,
Bogdan
Comment 8 Andrey Loskutov CLA 2021-11-19 08:19:29 EST
(In reply to Bogdan Oprea from comment #7)
> Could you please let me know what am I doing wrong? How can I reproduce this
> bug in Eclipse 4.11?

No steps with application, but you can "emulate" slow build

1) Put a conditional breakpoint after lock.acquire(); in org.eclipse.core.internal.resources.WorkManager.checkIn(ISchedulingRule, IProgressMonitor) and add Thread.sleep(5000) in the breakpoint expression.
2) Open Java file
3) Start Project -> Clean.. -> All projects
4) Type anything in the opened java file
5) Editor / UI will be frozen with no progress dialogs etc.
Comment 9 Bogdan Oprea CLA 2021-11-19 09:35:22 EST
(In reply to Andrey Loskutov from comment #8)
> (In reply to Bogdan Oprea from comment #7)
> > Could you please let me know what am I doing wrong? How can I reproduce this
> > bug in Eclipse 4.11?
> 
> No steps with application, but you can "emulate" slow build
> 
> 1) Put a conditional breakpoint after lock.acquire(); in
> org.eclipse.core.internal.resources.WorkManager.checkIn(ISchedulingRule,
> IProgressMonitor) and add Thread.sleep(5000) in the breakpoint expression.
> 2) Open Java file
> 3) Start Project -> Clean.. -> All projects
> 4) Type anything in the opened java file
> 5) Editor / UI will be frozen with no progress dialogs etc.

But is this something that can be achieved from a user point of view?
Can a user really end up in this situation? Considering that adding breakpoints is not something they can do.
Comment 10 Andrey Loskutov CLA 2021-11-19 10:19:32 EST
(In reply to Bogdan Oprea from comment #9)
> But is this something that can be achieved from a user point of view?
> Can a user really end up in this situation? Considering that adding
> breakpoints is not something they can do.

The breakpoint only "emulates" slow work behind. So imagine builders do that slow work instead of the breakpoint, and you will answer your question. And for sure there are many ways how some build / file / system IO related operation can be slow.