Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 578871 - prevent UI freeze during UNDO operation + autobuild #6

Merged
merged 1 commit into from
Apr 13, 2022

Conversation

jukzi
Copy link
Contributor

@jukzi jukzi commented Apr 12, 2022

While JDT's refactoring correctly tries to interrupt autobuild the UNDO
of the same operation did not. In general all UNDO Operations did not
try to interrupt autobuild.

This adds dependency from ui to resources to make the History operations
become aware of resource scheduling rule.

from https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/192458

While JDT's refactoring correctly tries to interrupt autobuild the UNDO
of the same operation did not. In general all UNDO Operations did not
try to interrupt autobuild.

This adds dependency from ui to resources to make the History operations
become aware of resource scheduling rule.
@mickaelistria
Copy link
Contributor

As mentioned on Gerrit, I'm not really convinced that this a proper fix to the right problem. The actual problem is trying to begin a rule in the UI Thread should show some progress dialog. That would cover all cases of that kind without need for the operation to care about the progress report, and instead to focus on actually doing its job.
So I would rather not merge it. I will have more time for development in May and think I can implement a more general solution then.

@ghost
Copy link

ghost commented Apr 12, 2022

How about submit this and just revert if it makes any trouble or when you found a better solution?
(I have doubts you will find a general solution in time)

@mickaelistria
Copy link
Contributor

OK, let's do that.

@mickaelistria
Copy link
Contributor

I opened #8 about a general solution.

@jukzi jukzi merged commit d610ff2 into master Apr 13, 2022
@jukzi jukzi deleted the jukzi192458 branch April 13, 2022 06:37
try {
try {
// interrupt autobuild or show Wait/Cancel Dialog:
Runnable r = () -> manager.beginRule(rule, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change causes a regression. If the Undo task joins on a workspace rule, it hangs now.
So starting a rule here is not OK.
I would propose to revert the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the Undo task joins on a workspace rule

how to reproduce that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have custom IUndoableOperation (we have one that extends AbstractOperation) that runs operation in a different thread and there takes the workspace rule.

    @Override
    public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {

        IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
        try {
            progressService.run(true, false, new IRunnableWithProgress() {
                @Override
                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
                   Job.getJobManager().beginRule(rule, monitor); // here we hang now
                   // ... do something that needs workspace
                }
            });
        } catch (InvocationTargetException | InterruptedException e) {
        }

        return Status.OK_STATUS;
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, locking anything accessible to 3rd party code before starting undo is not OK, because "undo" in 3rd party code can require the same lock.

Also interesting (I haven't noticed that first), that the org.eclipse.ui.workbench bundle in question had no references to org.eclipse.core.resources bundle before, I think for a good reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants