Skip to content
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

Error : WakeLock finalized while still held #35

Open
GaelleJoubert opened this issue Jun 27, 2021 · 3 comments
Open

Error : WakeLock finalized while still held #35

GaelleJoubert opened this issue Jun 27, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@GaelleJoubert
Copy link

Hello,
I'm using this plugging to run a function (bluetooth scan) in background, even if the app is not "open".
As a way to try this plugging to see if it fit my need, I code a very easy app where when I tap a button, it launch the bluetooth scan as a "forground service", and when the same button is tap again, it stop the scan and the foreground service.

A few second after closing the foreground service, I have the following warning on my console :

"E/PowerManager(14614): WakeLock finalized while still held: FlutterBackgroundPlugin:Wakelock"

Even though the app seems to work fine. When I tap pthe button I can see my bluetooth scan starting (it prints the snaned devices), and when I tap it again, I can see the foreground service stoping (notification disapearing), and the bluetooth scan stopping as well.

Have you aver have this error ? Can i just igniore it, or did I do someting wrong ?
I pasted bellow the way I'm using the plugging :


//Android Config
final androidConfig = FlutterBackgroundAndroidConfig(
  notificationTitle: "My title",
  notificationText: "Bluetooth Scan in process",
  notificationImportance: AndroidNotificationImportance.Default,
  notificationIcon: AndroidResource(name: 'icon_foregroundService.png', defType: 'drawable'), 
);

//Function To start the foreground Service
void StartFGS() async {
  bool hasPermissions = await FlutterBackground.hasPermissions;
  bool success = await FlutterBackground.initialize(androidConfig: androidConfig);
  await FlutterBackground.enableBackgroundExecution();
  startBluetoothScan();
}

//Function to Stop The foreground service
void stopForegroundService() async{
  stopScanForDevice();
  //await FlutterBackground.initialize();
  await FlutterBackground.disableBackgroundExecution();
}

//The following function is in another file, and is called when the button is tapped :
void _toggleForegroundServiceOnOff() async {

    if (fgsIsRunning) {
      stopForegroundService();
      setState(() {
        fgsIsRunning = false;
      });
    }
    else {
      maybeStartFGS();
      setState(() {
        fgsIsRunning = true;
      });
    }
    }

Smartphone:

  • Device: Pixel 4 5G
@GaelleJoubert GaelleJoubert added the bug Something isn't working label Jun 27, 2021
@JulianAssmann
Copy link
Owner

JulianAssmann commented Oct 2, 2021

Strange. I'm explicitly setting the WakeLock not to be referenced counted:


So one call to release() should release the WackeLock no matter how many acquire() calls there were prior to it.

This bug should not be problem for your app though.

@JulianAssmann
Copy link
Owner

Which version did you use and is the problem fixed in the latest version?

@blackbusters
Copy link

I'm still experiencing this warning with latest version, and in real samsung devices, it used 100% cpu and freeze hang the app, was that had anything to do with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants