-
Notifications
You must be signed in to change notification settings - Fork 916
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
Add option for custom watchDog timer interval #313
Comments
If I implement this, you need to test many all android devices. |
I see your point. But iOS and iPhone > 5 do have good performance. Even running on 1ms is super fast and the map resets position like native. If you implement this, I would make if(iOS) ...setWatchDogTimer(10) else 100 or else nothing. Default is 100. |
Sounds like your app needs large battery. |
Also a very good point. But do you really think that calling an interval every 1ms will dramatically increase battery usage? Look at 3D Games... |
But with this method, I could set the interval to 1ms before menu animation, onfinish, reset to 100. This would be a great feature. |
+1 i agree, this option would be nice. leave a sensible default value and then leave it up to the developer to change if needed |
Another option would be:
Just as an extra. I only need to watch/refresh position when I open my navigation menu. It would be perfect to totally deactivate the watchDog and (cause my framework provides some "preopen" and "postopen" callbacks,) to do something like this. on.('preopen') -> on('postopen') -> on('preclose') -> on('postclose') -> This would have so many favours. Less battery comsuming application and much better animation, as the position get changes wihtout any delay. Please provide this feature at least as an additional options for us heavy users. |
+1, this really needs to be an option |
@bFlood are you in for a bounty? This is a very urgent feature for me. I guess if we both reach 50 bucks masashi will be in for doing this (I would do it myself, but I'm busy enough with the app) |
Sorry. You guys are already enough donated. I'm really appreciate for you. |
No problem. I will send PR in 10 minuntes ;) |
Hi @wf9a5m75 just add these lines before setCenter function in your JS. /**
* @desc Set watchDogTimer for map positioning changes
*/
App.prototype.getWatchDogTimer = function() {
var self = this;
time = self.get('watchDogTimer') || 100;
return time;
};
/**
* @desc Set watchDogTimer for map positioning changes
*/
App.prototype.setWatchDogTimer = function(time) {
var self = this;
time = time || 100;
self.set('watchDogTimer', time);
if(time < 50) {
console.log('Warning: watchdog values under 50ms will drain battery a lot. Just use for short operation times.');
}
}; And very close to the end, replace window._watchDogTimer = window.setInterval(function() { myFunc(); }, 100); with this one: window._watchDogTimer = window.setInterval(function() { myFunc(); }, _mapInstance.getWatchDogTimer()); You still can't cancel the watchdog (this option really should still be implemented, but for now, I could set a high value like 10000 which will save a lot more battery... You can set your own value with: Map.setWatchDogTimer(TIMEINMILLISECONDS); Value needs to be an integer. |
Here as a proof, the benefits are HUGE! OnsenUI has a preopen and a postopen, preclose and postclose callbacks for the menu. Workflow: Of course I could leave it on 1ms till postclose (which is much smarter I guess... nobdy is going to leave the menu open for more then a few seconds. |
Thank you, @hirbod |
Maybe you will find some time for adding the options for enable/disable totally. |
Hi,
actually the watchdog-timer is set to 100ms.
https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/master/www/googlemaps-cdv-plugin.js#L2018
Could you please provide a function to override the value or even disable it? (false = disabled, 0 = disbaled, 1 = 1ms, 20 = 20ms... etc)
The text was updated successfully, but these errors were encountered: