Flashlight-PhoneGap-Plugin icon indicating copy to clipboard operation
Flashlight-PhoneGap-Plugin copied to clipboard

Severe execution blocking

Open StephanBijzitter opened this issue 10 years ago • 7 comments

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.

StephanBijzitter avatar Jan 12 '15 09:01 StephanBijzitter

On which platform did you experience this?

EddyVerbruggen avatar Feb 23 '15 19:02 EddyVerbruggen

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.

crissi avatar May 05 '15 11:05 crissi

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;

        });

      }

  });

}

ElodieC avatar Jun 26 '15 17:06 ElodieC

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

lucasdupin avatar Oct 26 '15 21:10 lucasdupin

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?

EddyVerbruggen avatar Oct 26 '15 21:10 EddyVerbruggen

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.

lucasdupin avatar Oct 26 '15 22:10 lucasdupin

FYI On Android the plugin now executes everything on a background thread (v 3.1.0)

EddyVerbruggen avatar Jun 14 '16 08:06 EddyVerbruggen