Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » ModelJobs not working when focus is out
ModelJobs not working when focus is out [message #1850021] Fri, 11 February 2022 09:08 Go to next message
Luka Cavic is currently offline Luka CavicFriend
Messages: 47
Registered: August 2014
Member
Hi,

I have created ModelJob to run some job (fetch location using requestGeolocation() method) in Desktop.java in execInit method. (Also tried in execOpened and execGuiAttached).

This is working ok, if application is active and focused. But job stops working when:

1. We open another tab in browser
2. When we minimize browser
3. When we open another browser with another page

Is it possible to always run job to requestGeolocation even if application is out of focus.

This is code for ModelJob:
ModelJobs.schedule(() -> {
findLocationForTeam();
}, ModelJobs.newInput(ClientRunContexts.copyCurrent())				
.withExecutionTrigger(Jobs.newExecutionTrigger().
withStartIn(5,TimeUnit.SECONDS)
.withSchedule(FixedDelayScheduleBuilder.repeatForever(10, TimeUnit.SECONDS)))
					.withExceptionHandling(new ExceptionHandler() {

						@Override
						public void handle(Throwable t) {
							System.err.println("Error with JOB: " + t);
						}
}, true));


I also tried to set property isTrackFocus on Desktop.java to false, but have same problem.

Thank you!
Re: ModelJobs not working when focus is out [message #1850023 is a reply to message #1850021] Fri, 11 February 2022 09:26 Go to previous messageGo to next message
Luka Cavic is currently offline Luka CavicFriend
Messages: 47
Registered: August 2014
Member
I think I solved it. It is Jobs.schedule, not ModelJobs
Re: ModelJobs not working when focus is out [message #1850025 is a reply to message #1850023] Fri, 11 February 2022 10:17 Go to previous messageGo to next message
Luka Cavic is currently offline Luka CavicFriend
Messages: 47
Registered: August 2014
Member
Not working. I have error that only ModelJobs can update UI model.

Can someone help me?

Thank you
Re: ModelJobs not working when focus is out [message #1850033 is a reply to message #1850025] Fri, 11 February 2022 15:41 Go to previous message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
Hi Luka

The whole geolocation magic happens in the JS part of the application. The Java part in Desktop.java only sends an event to the browser, which results in a call to the "navigator.geolocation" API and returns the results in a JSON response. You should see that request/reponse when you open the network panel (F12) an look at the JSON requests.

I did not test it but I can imagine, that the browser does not respond to calls to the geolocation API when the browser tab/window is not active - it would make sense, because you don't want a malicious website to access your location in the background. You might need to debug into DesktopAdapter.js#_onRequestGeolocation to see what happens in your case.

I'd recommend to check first if the geolocation API responds to calls when the browser is in the background, in a plain HTML/JavaScript environment for instance with https://jsfiddle.net/.

Cheers
André


Eclipse Scout Homepage | Documentation | GitHub
Previous Topic:22.0-beta1: Classic App not loading after successful login
Next Topic:How to add Content Security Policy frame-ancestors?
Goto Forum:
  


Current Time: Wed May 08 09:45:41 GMT 2024

Powered by FUDForum. Page generated in 0.03888 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top