Bug 578578 - fix API to interrupt autobuild
Summary: fix API to interrupt autobuild
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 4.23   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.24 M1   Edit
Assignee: Jörg Kubitz CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 518665 (view as bug list)
Depends on: 578639 578640
Blocks:
  Show dependency tree
 
Reported: 2022-02-04 05:06 EST by Jörg Kubitz CLA
Modified: 2022-03-08 06:24 EST (History)
2 users (show)

See Also:


Attachments
Screenshot cancel dialog (9.59 KB, image/png)
2022-02-04 05:06 EST, Jörg Kubitz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jörg Kubitz CLA 2022-02-04 05:06:16 EST
Created attachment 287981 [details]
Screenshot cancel dialog

Autobuilds blocks any user operation requiring a workspace rule, and that can be a long time on big projects.
In that case the user has the possibility to manually cancel either the user operation or the autobuild. (or gets a UI freeze if the user operation does not use the approriate API to show that dialog!)
It would be better if the autobuild is automatically canceled in that case and resumed after the user operation.
We already have custom operations which use that pattern for a long time, but there is no public API for that.

I request either of these:
a) Add a public API (basicly simply like core.internal.events.BuildManager.shutdown())
b) Change the existing API to cancel the current Autobuild when Autobuild is changed to disabled. (Currently autobuild is restarted when autobuild is enabled but not stopped when disabled)

Further i ask to use that feature for either
c) certain existing jobs that we know that should have precedence over autobuild (like saving a file).
d) generically use it for all operations that request a conflicting rule. Since the autobuild should restart after the user operation i don't see a problem.

i would prefer a) and d)
Comment 1 Jörg Kubitz CLA 2022-02-07 07:48:39 EST
i just found there already exist such a concept with BuildManager.interrupt() called from Workspace.prepareOperation(ISchedulingRule, IProgressMonitor). I need to investigate why that does not work as intended in some use-cases.
Comment 2 Jörg Kubitz CLA 2022-02-08 04:16:38 EST
Two problems:
1. minor race condition: autobuild will retry to resume after interrupt. If it is faster in acquiring the ISchdeulingRule lock again than the User action, then the User actions interrupt() event is lost (bug 170356 tried to fix that but just relies on scheduling delay).

2. Many useractions do not try to interrupt (by using Workspace.prepareOperation) but call JobManager.beginRule() directly. In special all actions that use org.eclipse.ui.progress.IProgressService.runInUI() - which shows that waiting dialog.

the challenge: org.eclipse.platform.ui does not know about org.eclipse.platform.resources (well except org.eclipse.ui.internal.LegacyResourceSupport)

there is also a related test:
org.eclipse.core.tests.internal.builders.BuilderTest.testInterruptAutobuild()

I think it needs to extend Job with a method to request interrupt - which autobuild needs to listen on.
Comment 3 Jörg Kubitz CLA 2022-02-08 07:34:47 EST
3. even if interrupt() is triggered. literally only AUTO_BUILD is interrupt but not INCREMENTAL_BUILD - even though it was automatically triggered in my case:

BuildManager.basicBuildLoop automatically elevates INCREMENTAL_BUILD to INCREMENTAL_BUILD after every iteration - which especially comes into play when xtext requests a second round.
Comment 4 Eclipse Genie CLA 2022-02-08 07:42:20 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/190559
Comment 5 Andrey Loskutov CLA 2022-02-08 08:49:40 EST
(In reply to Eclipse Genie from comment #4)
> New Gerrit change created:
> https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/190559

See bug 10262 comment 40. The changed lines were added to support multiple build cycles. Please check that the proposed change is not breaking *real* cyclic builds (not just those from Xtext builder unhappy with something).
Comment 7 Eclipse Genie CLA 2022-02-11 07:55:30 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/190715
Comment 8 Jörg Kubitz CLA 2022-02-21 05:30:32 EST
*** Bug 518665 has been marked as a duplicate of this bug. ***