eclipse-platform / eclipse.platform.ui

Eclipse Platform
https://projects.eclipse.org/projects/eclipse.platform
Eclipse Public License 2.0
81 stars 182 forks source link

UI freeze monitoring should be possible also in tests #1670

Open frankbenoit opened 8 months ago

frankbenoit commented 8 months ago

In an RCP application I want to use the UI freeze monitoring.

I found that the activation is depending on Platform.inDevelopmentMode(). This method detects if the application was started with the -dev option. I assume this is to avoid events to be triggered if a debugger is connected or if the application is started from inside an IDE.

However, also maven tycho surefire uses this option, hence in our Jenkins builds, UI freezes are not detectable.

Could you make it possible to have this detection available in maven builds as well?

Proposal solution

Have a test method which detects if a debugger is present.

RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
return runtime.getInputArguments().toString().contains("jdwp");
iloveeclipse commented 8 months ago

We have freeze monitoring enabled in SDK, without starting it in debug mode. So why is this a problem to have it enabled in RCP?

frankbenoit commented 8 months ago

It is not active in Jenkins surefire, is it? Because this is what I am missing. The reason I found is, that surefire makes use of -dev option, hence the freeze monitoring is disabled.

iloveeclipse commented 8 months ago

OK, this was misleading. So freeze monitoring is working in RCP but not working in tests. Would be easier to understand if the title would say that.

Contributions are welcome.

laeubi commented 8 months ago

OK, this was misleading. So freeze monitoring is working in RCP but not working in tests. Would be easier to understand if the title would say that.

No it is not working if one passes the -dev option to RCP/launch/Eclipse/Whatever...

frankbenoit commented 8 months ago

@laeubi yes I did describe this, I know it is not working at the moment if the -dev option is passed.

https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/bundles/org.eclipse.ui.monitoring/src/org/eclipse/ui/internal/monitoring/MonitoringStartup.java#L46

I guess, this option cannot be avoided on surefire side.

Now I want to have the behavior changed, so the UI freeze events are also logged in surefire tests. Perhaps by detecting a debugger, instead of using the -dev argument as the condition.

laeubi commented 8 months ago

@frankbenoit this was regarding @iloveeclipse comment that it does nor working in tests (what is wrong), it is just a sideeffect because the surefire-test are using the -dev option (as you correctly described).