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

Show progress indicator of "Run configurations..." after delay #591

Conversation

fedejeanne
Copy link
Contributor

@fedejeanne fedejeanne commented Jul 25, 2023

Wait 1 second before showing the progress indicator in the dialog "Run configurations...". This avoids the flickering that happens when the task is completed in under 1 second.

Contributes to eclipse-pde/eclipse.pde#679

@github-actions
Copy link
Contributor

github-actions bot commented Jul 25, 2023

Test Results

       42 files  ±0         42 suites  ±0   57m 2s ⏱️ ±0s
  3 771 tests ±0    3 767 ✔️  - 1    3 💤 ±0  1 +1 
11 316 runs  ±0  11 288 ✔️  - 1  27 💤 ±0  1 +1 

For more details on these failures, see this check.

Results for commit c0b72e9. ± Comparison against base commit 7ed493c.

♻️ This comment has been updated with latest results.

@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch 2 times, most recently from 3a9124c to f830a3f Compare July 26, 2023 13:36
@fedejeanne fedejeanne marked this pull request as ready for review July 26, 2023 13:37
@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch from f830a3f to 843f79f Compare July 26, 2023 13:38
Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

Looks reasonable.

If nobody else does in the meantime, I'll try to review this in detail and try it out at the weekend.

fActiveRunningOperations++;

UIJob showProgressMonitorPart = createJobToShowProgressMonitorPart();
// only show the progress bar if necessary after 1 second
showProgressMonitorPart.schedule(1_000);
Copy link
Member

Choose a reason for hiding this comment

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

Since potentially not everybody wants a delay, maybe the delay should be configurable in the context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean like DebugUIPlugin.getDefault().getPreferenceStore().getLong("somelong"); ? That would also mean that there needs to be a new preference in the Preferences dialog under Run/Debug > Launching > Launch configurations, right?

Or did you mean something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since potentially not everybody wants a delay, maybe the delay should be configurable in the context?

I was thinking again about making it configurable and it still doesn't feel right.

Don't get me wrong, I'm all for customizing the user experience but in this particular case, a low value would mean that the progress bar might flicker and a high value would mean the UI might freeze. Letting the user set this value feels like giving him/her the choice between bad and worse 😅

Maybe you and I can settle for a value and let it hard-coded. Say 500 ms?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is definitely a tradeoff with configuration preferences that users are unlikely to find and as there are more and more, the user is even less likely to find and understand such things...

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the late reply.
I meant not configurable for the user but for developers calling this code.

If a dev knows that an operation will definitvly take some time, it would be good to show i immediatly.

Furthermore If we could somehow estimate the remaining runtime(e.g. from a ProgressMonitor, it would be good to consider if it is worth to show it.
E.g. for a 501ms running Task showing Progress after 500ms is pointless.

Copy link
Member

Choose a reason for hiding this comment

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

I meant not configurable for the user but for developers calling this code.

Thank you for clarifying it :-) . Do you have any suggestion (code) on how to achieve that?

Not really, I would guess that this should somehow be stored in the context? But this is just a simple guess, there might be better places.

Furthermore If we could somehow estimate the remaining runtime(e.g. from a ProgressMonitor, it would be good to consider if it is worth to show it.

Hm, the problem is that the progress monitor does not have any method to see how much work is still to be done so there is no basis to estimate if it's worth showing it.

E.g. for a 501ms running Task showing Progress after 500ms is pointless.

I agree and I'm convinced pretty much any value someone selects will end up provoking either a flickering or a UI freeze. The timeout is just a simple way of catching all jobs that run in under X ms. I have no way of knowing how long a job is going to take, but In my experience if the job takes > 1s then it will probably take >2 s (i.e. the progress bar will appear for at least a second). Again, this is a very simplistic approach based on my experience. I wanted to provide a solution without burdening the user (or programmer) with a new setting/parameter that needs to be understood and set correctly.

Makes sense. So my suggestion is for now to just a threshold a developer can add and maybe later enhance the progress-manager to get an (probably quickly outdated) estimation about the done work later and with that enhance this further.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, I would guess that this should somehow be stored in the context?

Sorry to insist but I don't understand. What context do you mean?

Surely not the org.eclipse.e4.core.contexts.IEclipseContext, right?
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, you probably meant the BundleContext right? I'll look into it on Monday.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, you probably meant the BundleContext right? I'll look into it on Monday.

I think it should be a org.eclipse.jface.operation.IRunnableContext, as you are using that in eclipse-pde/eclipse.pde#674 to show the pop-up that shows the progress indication.
Unfortunately the progress-indicator is not created directly so have to pass trough the threshold value.

Copy link
Member

Choose a reason for hiding this comment

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

Btw. Monday is the last day of development for the upcomming 2023-09 release and I probably won't have the time to review/try this Monday evening (if another Committer does it is of course welcome).

I'll try to review your PR in PDE over the weekend, but cannot promise it.

@Bananeweizen
Copy link
Contributor

The topic of "deferred progress reporting" is also handled within org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog (which is probably a copy of org.eclipse.debug.internal.ui.viewers.model.TimeTriggeredProgressMonitorDialog). Not sure if you could reuse the first one in your implementation maybe.

@fedejeanne
Copy link
Contributor Author

fedejeanne commented Aug 14, 2023

The topic of "deferred progress reporting" is also handled within org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog (which is probably a copy of org.eclipse.debug.internal.ui.viewers.model.TimeTriggeredProgressMonitorDialog). Not sure if you could reuse the first one in your implementation maybe.

Good hint @Bananeweizen, I didn't know about that one, thank you! This could be a good compromise since the concept of delayed progress reporting has already been tackled and it seems a delay of 800 ms is the accepted norm. I changed the code to simply use this threshold in a21c1d7.

What do you say if we just take this implementation out for a spin in the upcoming release and see how this works, @HannesWell? Maybe this simple solution is better than letting the user/programmer set a value that will probably be quickly outdated anyway?

@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch from 843f79f to a21c1d7 Compare August 14, 2023 08:01
@fedejeanne
Copy link
Contributor Author

Hello all,
there has been little activity on this one in the past few weeks. Any chance we can resume this PR for 4.30?

@mickaelistria mickaelistria force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch from a21c1d7 to 52070f1 Compare September 11, 2023 07:36
@mickaelistria mickaelistria added this to the 4.30 M1 milestone Sep 11, 2023
@mickaelistria
Copy link
Contributor

As build log mentions, a version bump seems necessary:

[ERROR] Failed to execute goal org.eclipse.tycho.extras:tycho-p2-extras-plugin:4.0.2:compare-version-with-baselines (compare-attached-artifacts-with-release) on project org.eclipse.debug.ui: Only qualifier changed for (org.eclipse.debug.ui/3.18.100.v20230911-0736). Expected to have bigger x.y.z than what is available in baseline (3.18.100.v20230802-1257) -> [Help 1]

@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch 2 times, most recently from 77899f2 to 3229184 Compare September 11, 2023 13:12
@fedejeanne
Copy link
Contributor Author

As build log mentions, a version bump seems necessary:

[ERROR] Failed to execute goal org.eclipse.tycho.extras:tycho-p2-extras-plugin:4.0.2:compare-version-with-baselines (compare-attached-artifacts-with-release) on project org.eclipse.debug.ui: Only qualifier changed for (org.eclipse.debug.ui/3.18.100.v20230911-0736). Expected to have bigger x.y.z than what is available in baseline (3.18.100.v20230802-1257) -> [Help 1]

Thank you for the hint. It's odd, I just bumped the version and I get this error in Eclipse:

image

Any hint on how to get rid of it?

@iloveeclipse
Copy link
Member

Any hint on how to get rid of it?

You should set API baseline to 4.29 RC2a. I assume you are still using 4.28 in the IDE.

@merks
Copy link
Contributor

merks commented Sep 11, 2023

FYI, the Oomph setups won't be correct (correct baseline and TP) until Wednesday morning...

@fedejeanne
Copy link
Contributor Author

FYI, the Oomph setups won't be correct (correct baseline and TP) until Wednesday morning...

i.e. Perform setup tasks won't help until (late) Wednesday, right?

image

@merks
Copy link
Contributor

merks commented Sep 11, 2023

As a workaround, you can do this. Use Navigate -> Open Setup -> Workspace and copy (select text below) and paste (onto the root Workspace object) these two redirection tasks

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:setup="http://www.eclipse.org/oomph/setup/1.0">
  <setup:RedirectionTask
      sourceURL="https://download.eclipse.org/eclipse/updates/4.28/R-4.28-202306050440"
      targetURL="https://download.eclipse.org/eclipse/updates/4.29/R-4.29-202309031000"/>
  <setup:RedirectionTask
      sourceURL="https://download.eclipse.org/eclipse/updates/4.29-I-builds"
      targetURL="https://download.eclipse.org/eclipse/updates/4.30-I-builds"/>
</xmi:XMI>

Then the baseline task will use the 4.29 release and the target platform will use 4.30 I builds...

image

@HannesWell
Copy link
Member

This could be a good compromise since the concept of delayed progress reporting has already been tackled and it seems a delay of 800 ms is the accepted norm. I changed the code to simply use this threshold in a21c1d7.

Sounds good.
While in some cases callers might want to adjust this value, most callers are probably happy with a reasonable default. So I think it is sufficient to add that posibility when there is a demand for it.

I'm still thinking about if it would be good to add means to IProgressMonitor to get the percentage of work done (or at least an Approximation since the value can be outdated quickly)? This would allow to estimate if it is worth to open the progress indicator.
On the other hand it highly depends on the called code if, for example the last 20% really take only 20% of the total time or more or less. I have seen it often that the indicator got stuck at 80/90% for a long time. And there is even a recommendation to just half the work remaining all the time if the total work is unknown.
So overall I'm not sure if that is worth it.

@laeubi
Copy link
Contributor

laeubi commented Sep 12, 2023

I'm still thinking about if it would be good to add means to IProgressMonitor to get the percentage of work done (or at least an Approximation since the value can be outdated quickly)? This would allow to estimate if it is worth to open the progress indicator.

the implementation of the monitor should/must handle this so there is no need for an public API at all, so for example ProgressMonitorDialog could have something similar to what Swing uses here:

https://docs.oracle.com/javase%2F7%2Fdocs%2Fapi%2F%2F/javax/swing/ProgressMonitor.html#setMillisToDecideToPopup(int)

@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch from 3229184 to 1112f1e Compare September 12, 2023 07:37
@@ -1409,6 +1416,20 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable
}
}

private UIJob createJobToShowProgressMonitorPart() {
return new UIJob(IInternalDebugCoreConstants.EMPTY_STRING) {
Copy link
Member

Choose a reason for hiding this comment

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

Besides UIJob.create() I think we can just use an empty string literal here.
IMHO it does not make sense to get that from a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 6c443cc

@HannesWell
Copy link
Member

I'm still thinking about if it would be good to add means to IProgressMonitor to get the percentage of work done (or at least an Approximation since the value can be outdated quickly)? This would allow to estimate if it is worth to open the progress indicator.

the implementation of the monitor should/must handle this so there is no need for an public API at all, so for example ProgressMonitorDialog could have something similar to what Swing uses here:

https://docs.oracle.com/javase%2F7%2Fdocs%2Fapi%2F%2F/javax/swing/ProgressMonitor.html#setMillisToDecideToPopup(int)

But the ProgressMonitor is designed differently and does not handle the context, so there must be at least and internal method to get that value.

Any way, since everything additionally seems to be more complex, I think this is fine as a first step, with the two minor points (using the UIJob-factory and the empty string) fixed I would be fine to submit this.

@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch 2 times, most recently from 694a2e4 to f50e586 Compare September 13, 2023 05:28
@laeubi
Copy link
Contributor

laeubi commented Sep 13, 2023

But the ProgressMonitor is designed differently and does not handle the context, so there must be at least and internal method to get that value.

The value should be passed to the dialog and then it could handle it internally, but users of that Interface must not care nor do we need to store such values in general...

@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch from f50e586 to 6c443cc Compare September 13, 2023 05:32
Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Does anybody else plan to review this?

@fedejeanne you need to bump the Micro version segment in in the Manifest order to fix the build failure:

[ERROR] Failed to execute goal org.eclipse.tycho.extras:tycho-p2-extras-plugin:4.0.2:compare-version-with-baselines (compare-attached-artifacts-with-release) on project org.eclipse.debug.ui: Only qualifier changed for (org.eclipse.debug.ui/3.18.100.v20230913-0532). Expected to have bigger x.y.z than what is available in baseline (3.18.100.v20230802-1257) -> [Help 1]

@HannesWell
Copy link
Member

But the ProgressMonitor is designed differently and does not handle the context, so there must be at least and internal method to get that value.

The value should be passed to the dialog and then it could handle it internally, but users of that Interface must not care nor do we need to store such values in general...

I think we have a missunderstanding here. The amount of work done is interesting do help deside if after the Initial delay it is worth for the remaining time to show the Pop-up.

Making the initial delay configurable is an orthogonal issue.

@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch from 6c443cc to d2a2ce2 Compare September 13, 2023 08:30
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

Changes look good to me. I only have a minor remark w.r.t. to a code comment.

Wait a while before showing the progress indicator in the dialog "Run
configurations...". This avoids the flickering that happens when the
task is completed in under 800 ms (which is the current norm in
PlatformUI.getWorkbench().getProgressService().getLongOperationTime())

Contributes to eclipse-pde/eclipse.pde#679
* org.eclipse.debug.ui --> 3.18.200
@fedejeanne fedejeanne force-pushed the enhancements/show-progress-in-run-configurations-dialog-after-delay branch from d2a2ce2 to c0b72e9 Compare September 13, 2023 09:01
Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

Thank you @fedejeanne for this PR and your patience.

On the last pass I thought about if fActiveRunningOperations should be turned into a AtomicLong, but since the code is running in the UI thread in both cases (just later) that's fine.

Submitting.

I'll have a look at the PDE pendant in the next days.

@HannesWell HannesWell merged commit f999b9d into eclipse-platform:master Sep 13, 2023
14 of 16 checks passed
@fedejeanne fedejeanne deleted the enhancements/show-progress-in-run-configurations-dialog-after-delay branch September 14, 2023 04:00
@fedejeanne
Copy link
Contributor Author

Thank you @fedejeanne for this PR and your patience.

Thank you for reviewing!

I'll have a look at the PDE pendant in the next days.

Looking forward to it :-)

@laeubi
Copy link
Contributor

laeubi commented Sep 18, 2023

FYI, the Oomph setups won't be correct (correct baseline and TP) until Wednesday morning...

Just to make sure was this meant to be 13.09.2023? The setup still fails for me and I can't use the baseline...

@merks
Copy link
Contributor

merks commented Sep 18, 2023

It doesn't look like this?

image

@laeubi
Copy link
Contributor

laeubi commented Sep 18, 2023

It seems that Oomph was confused by the pre-req-target project imported as a project in my workspace somehow :-
At laest now I removed that project and it seems to came across the point now...

@merks
Copy link
Contributor

merks commented Sep 18, 2023

Yes, there was a problem caused by the two occurrences and the "wrong" one winning. That should no longer happen because of the filter in the .project file.

@laeubi
Copy link
Contributor

laeubi commented Sep 18, 2023

Alright it seems I was now able to get the API error (hurray!):

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

8 participants