Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324993 - [Edit] Run diff computations as Jobs not Runnables
Summary: [Edit] Run diff computations as Jobs not Runnables
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Compare-Inbox CLA
QA Contact: Tomasz Zarna CLA
URL:
Whiteboard: stalebug
Keywords: investigate
Depends on: 326330
Blocks: 304693 326680 326683
  Show dependency tree
 
Reported: 2010-09-10 12:45 EDT by Tomasz Zarna CLA
Modified: 2019-11-14 03:14 EST (History)
4 users (show)

See Also:


Attachments
Patch that makes the "Finding diffs" dialog easier to observe (4.06 KB, patch)
2010-09-24 06:05 EDT, Tomasz Zarna CLA
no flags Details | Diff
mylyn/context/zip (33.66 KB, application/octet-stream)
2010-09-24 06:05 EDT, Tomasz Zarna CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Zarna CLA 2010-09-10 12:45:33 EDT
Currently, diff computations required by the Compare Editor are run as IRunnableWithProgress in the given ICompareContainter which extends IRunnableContext. This works fine, but there is a small issue with it. If you quickly open several Compare editors from the Sync view and the first one starts to calculate its diffs a model dialog will pop up showing the progress. The problem is that if the dialog is up you can cancel only the computation for that editor, if another computation starts in the meantime there is no way to cancel it. A way out from this situation could be running diff computation as Jobs so the progress will be shown in the in the Progress View for each of the job separately.

Another solution could be showing the progress inside the Compare editor as Dani suggested in bug 322329, comment 5.
Comment 1 Tomasz Zarna CLA 2010-09-10 13:01:01 EDT
Even though this bug looks like a blocker to bug 322329 I don't think a fix for this bug will be something we would like to backport to 3.6.x, which will eventually happen to bug 322329.
Comment 2 Tomasz Zarna CLA 2010-09-10 13:11:25 EDT
Consider a scenario when you've opened two compare editors. As soon as the "Finding diffs" dialog shows up you hit cancel on it. The first algo is cancelled, but does the other one do? Of course, it hasn't been cancelled so it's still running. What's interesting the modal dialog stays up for that time, even though it doesn't show any progress and the Cancel button is disabled (you've just hit it for the first algo). As the result you have to wait for the second algo to stop without a way to cancel it.

Once bug 307280 is fixed this could become a serious issue for long running uncapped diff algorithms!
Comment 3 Tomasz Zarna CLA 2010-09-13 06:30:40 EDT
Prakash, you're an expert in that matter[1]. Is the above an expected behavior when we run multiple runnables via PlatformUI.getWorkbench().getProgressService().run(boolean, boolean, IRunnableWithProgress) (using ProgressManager in this particular case)? Or is there something wrong with our runnables or the way we run them? Is moving to Jobs the only option?

[1] http://blog.eclipse-tips.com/2009/02/using-progress-bars.html
Comment 4 Prakash Rangaraj CLA 2010-09-24 01:36:46 EDT
The major problem seems to be not passing the IProgressMonitor down and not honoring the cancellation. So even if the user presses Cancel, nothing happens. Now that the related Bug# 322329 is fixed, as soon as the user presses cancel (and the operation responds to it), the dialog should go away. Is that not happening now?
Comment 5 Tomasz Zarna CLA 2010-09-24 06:04:22 EDT
(In reply to comment #4)
> Is that not happening now?

It is, if you open a single compare editor. However if you schedule multiple comparisons (e.g. by opening files from the Sync view) you will get blocked with the dialog even though you have hit cancel on it. Apparently, the dialog is up as long as all scheduled runnabbles are running (see comment 0 and comment 2)
Comment 6 Tomasz Zarna CLA 2010-09-24 06:05:48 EDT
Created attachment 179509 [details]
Patch that makes the "Finding diffs" dialog easier to observe
Comment 7 Tomasz Zarna CLA 2010-09-24 06:05:51 EDT
Created attachment 179510 [details]
mylyn/context/zip
Comment 8 Krzysztof Kazmierczyk CLA 2010-09-24 07:36:26 EDT
From my initial investigation there is wrong ProgressMonitorDialog$ProgressMonitor instance notified about cancelation.

I observed, that cancleation works only for last compared document. In other words when your are comparing e.g. 3 documents, it only works when you hit cancel on when first two has been compared and third is comparing. It may suggest, that there is always cancelled last created thread (I did not check it, it is only my guessing.)
Comment 9 Tomasz Zarna CLA 2010-09-24 08:18:30 EDT
(In reply to comment #8)
> It may suggest, that there is always cancelled last created thread 

I thought it's the other way round but I may be wrong. Anyway, can you confirm that the dialog is up blocking the user as long as long as at least one runnabble is running even though the Cancel has been hit? This is my major concern -- the blocking dialog with no way of closing it.
Comment 10 Krzysztof Kazmierczyk CLA 2010-09-27 10:44:07 EDT
Tomek, I am confirming that for all compared documents except last one the dialog blocks any user actions I can click "Cancle" but once I click it, the button becomes inactive and I must wait until comparing ends.

What I also observed, that for me there is only one IrunableWithProgress running at the time. Next runnable starts only when comparing previous files ended.

Moreover when comparing many files, there is opened new progress dialog for each file. When we talked with Tomek today, he said he has only one progress dialog for all files. Tomasz, can you confirm that?
Comment 11 Tomasz Zarna CLA 2010-09-27 11:17:05 EDT
(In reply to comment #10)
> When we talked with Tomek today, he said he has only one progress dialog
> for all files. Tomasz, can you confirm that?

Yes, I was pretty sure I was dealing with a single dialog. I had a chat with Prakash today during which he managed to reproduce the problem on his side. He also said that it looks like a single dialog. At the same time he hacked a sample plug-in that does the same thing Compare does with the Runnables but this time he got a separate dialog for each runnable. There is definitely something wrong going on here, and Prakash promised to take a closer look at it.
Comment 12 Prakash Rangaraj CLA 2010-09-27 13:58:38 EDT
Tomasz,

    As I suspected, the IProgressService.run is called from two different threads. One checks whether its ok to open the editor and the other tries to computes the differences. When this (call from different threads to IProgressService.run) happens, and the user presses cancel, the UI appears to be frozen. I'm able to reproduce it without the team/compare coding. This is being addressed in the Bug# 326330
Comment 13 Tomasz Zarna CLA 2010-10-18 06:22:51 EDT
I'm holding off with targeting this bug to a particular milestone until bug 326330 gets addressed. If fixing that bug didn't solve the issue from comment 0, I would reconsider fixing this bug.
Comment 14 Lars Vogel CLA 2019-11-14 03:14:17 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.