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
Devices don't lock when service is running #157
Comments
hi @insertjokehere that seems to be the cause, maybe we can add a Method Channel to release the lock when the flutter engine runs successfully. |
@insertjokehere I have published 2.1.1 to fix this issue. Could you confirm if it's solved? |
Thanks for the quick turn around, I'll let you know how it goes when I have
a chance to test next week.
…On Fri, 27 May 2022, 10:25 pm Eka Setiawan Saputra, < ***@***.***> wrote:
@insertjokehere <https://github.com/insertjokehere> I have published
2.1.1 to fix this issue. Could you confirm if it's solved?
—
Reply to this email directly, view it on GitHub
<#157 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABE344VXS5NES563CGQTRLVMCPKJANCNFSM5XDAP75A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi, Looking at the fix c083025 it seems like the library still acquires a full wake lock when the background service starts, but releases it after 10 minutes, or when the main application interacts with the service. A couple of questions:
|
@insertjokehere I added the timeout just for backup. The wakelock will be released when the flutter engine is started. You can find the release command here https://github.com/ekasetiawans/flutter_background_service/blob/master/packages/flutter_background_service_android/android/src/main/java/id/flutter/flutter_background_service/BackgroundService.java at line 253 |
Thats great, thanks for clarifying. I guess my question is more why does the library need a full wake lock in the first place? Full wake lock is a really extreme lock to acquire - it turns the screen on full brightness, stops it from turning off at all and locks the CPU into full power mode. Before #92, the library acquired a partial wake lock that keeps the CPU on but does let it throttle down if needed, why was that insufficient? Would partial wake lock + the new timeout logic work? Or is there some reason why a full wake lock is needed in order to make sure the service starts properly? |
@insertjokehere afaik, we need wake lock for making boot receiver works. If you have any other strategy, feel free to make a pull request. :) |
Ah, makes sense. Thanks! |
This problem seems to also exist in iOS. I tested on an iPhone with the latest version of this package. Swift not being my cup of tea, even after reading the code, I am not certain why. |
@iovasquez That's weird, we don't do a wakelock like we have done on Android. |
Yes, after talking with my team: it was a miscommunication of which platform was being tested. (while I did test on iOS also, the issue I had had another cause) Thank you for your quick answer! |
Hi, first of all - thanks for great plugin:)
Only solution I come out with is - if
then maybe it should depend on auto_start_on_boot variable? When it is false we don't need to lock. I ran tests on: [√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [Version 10.0.19044.1706], locale pl-PL) |
Hi @ekasetiawans |
I just released flutter_background_service:^2.1.3 to fix this issue, please reply this issue if the problem persists and i will reopen it. |
I have tested your fix on
and everything works great, thanks for your work! I'm curious, can you tell in a few words what was the problem? |
@Grand-87 the wake lock acquired multiple times by the watchdog receiver but only released once. So, I move the acquire command to the correct location to make sure it's called once. |
Thanks for your awesome plugin!
I've implemented a foreground service on Android, but in my testing I have noticed that devices won't lock automatically or even dim their screens when the service is running. It appears that this is caused by this library acquiring a full wake lock:
https://github.com/ekasetiawans/flutter_background_service/blob/master/packages/flutter_background_service_android/android/src/main/java/id/flutter/flutter_background_service/BackgroundService.java#L53-L62
According to the docs, a full wake lock "Ensures that the screen and keyboard backlight are on at full brightness".
It looks like this was introduced in #92 - is it possible to override this behavior?
The text was updated successfully, but these errors were encountered: