Flashlight-PhoneGap-Plugin
Flashlight-PhoneGap-Plugin copied to clipboard
Severe execution blocking
So yeah, this plugin seems to block execution quite badly. I'm trying to make the flashlight flash (on off on off... etc) by calling toggle on every animation frame and the entire ui of my app is blocked, css animations get stuck and input isn't always processed anymore because the plugin takes way too long to execute.
It works well, but it is far from optimised.
On which platform did you experience this?
I get this warning during launch of my app on iOS (tried iphone 5s and iphone 4): THREAD WARNING: ['Flashlight'] took 36.587158' ms. Plugin should use a background thread.
Same issue here : it happens only on Samsung Galaxy S5 in cordova release mode and the toggle method is called when the user taps a button. The result is : the camera of the device is not working anymore, I have to manually kill the app to access the camera again. Here is the code :
var isOn = false;
....
if (window.plugins && window.plugins.flashlight) {
window.plugins.flashlight.available(function (isAvailable) {
if (isAvailable) {
window.plugins.flashlight.toggle(function () {
isOn = !isOn;
});
}
});
}
Android takes too long the turn its camera off and on again.
I implemented a third parameter to switchOff(null, null, true)
to avoid turning the camera off completely and changing only the flashlight parameter.
https://github.com/lucasdupin/Flashlight-PhoneGap-Plugin
Interesting addition. You'll only use that if you need to blink it repeatedly, right?
What happens if you use the soft switch off and open the camera app? Does it have trouble accessing the camera?
Right, only if you need to blink it repeatedly.
You must turn it off with switchOff();
to release the camera before quitting your app/activity.
But either way, this is something you are probably already doing.
FYI On Android the plugin now executes everything on a background thread (v 3.1.0)