aaassseee / screen_brightness

A Plugin for controlling screen brightness with application life cycle set and reset brightness implemented
https://pub.dev/packages/screen_brightness
MIT License
25 stars 22 forks source link

[bug][Windows] ~ScreenBrightnessWindowsPlugin() could cause Windows crash #23

Closed riyulu closed 11 months ago

riyulu commented 1 year ago

Description (bug summary)

crash in windows image

Why do you want to delete these two pointers?

image

Step to reproduce (how to reproduce the bug)

  1. git clone https://github.com/aaassseee/screen_brightness.git
  2. cd screen_brightness/screen_brightness/example && flutter run -d windows and quit
  3. open example.sln in visual studio 2022 and run project
  4. close windows

Platform (Android/iOS/macOS/Windows)

windows

aaassseee commented 1 year ago

Hi, @riyulu. Thanks for filing this issues. For the delete pointer question, because we need to release the memory when the plugin is getting destruct.

wanjm commented 1 year ago

I come across the same problem , which will cause window close very slowly

wanjm commented 1 year ago

comments the above two, there are still many other crash.

aaassseee commented 1 year ago

Hi @wanjm. Can you provide more info about the crash that you have faced?

aaassseee commented 1 year ago

Is that means the window close slowly after you press the close button?

riyulu commented 1 year ago

because we need to release the memory when the plugin is getting destruct.

@aaassseee hello, gays. My idea is that this memory is created externally and does not need to be released internally by the plugin. We should only delete the memory we create ourselves.

riyulu commented 1 year ago

And I have found there is a problem here, but I am not sure how to fix it.

aaassseee commented 1 year ago

Hi @riyulu. I found this artical, I am implementing this solution. Hopes it works.

aaassseee commented 1 year ago

Hi @riyulu. Is that only deleting windowhandler causing crashes? Not the registrar_?

aaassseee commented 1 year ago

Hi @riyulu @wanjm. I have updated screen_brightness_windows to 0.1.2. Please do a pub update to get the latest version to fix the issue.

aaassseee commented 1 year ago

Maybe #15 is also same with this issue.

riyulu commented 1 year ago

Hi @riyulu @wanjm. I have updated screen_brightness_windows to 0.1.2. Please do a pub update to get the latest version to fix the issue.

@aaassseee There are still some issues here. If I have time this weekend, I will raise a PR

aaassseee commented 1 year ago

@riyulu thanks for the contribution.

alexmercerind commented 1 year ago

I removed all delete statements altogether, no crash happens.

Is it necessary to have those? AFAIK destructor is only being called upon process termination.


Please proceed with your own intellect, not very sure about this.

aaassseee commented 1 year ago

I removed all delete statements altogether, no crash happens.

Is it necessary to have those? AFAIK destructor is only being called upon process termination.

Please proceed with your own intellect, not very sure about this.

Seems other Windows package does not delete pointer when destructor being called.

Maybe this is the solution.

aaassseee commented 1 year ago

Latest Windows package has been release. Please do a pub upgrade and check if there are any problems.

alexmercerind commented 1 year ago

Hi!

I appreciate your fixes. It does seem to work in my case.

Thanks!

aaassseee commented 1 year ago

Are there any crash after this fix?

alexmercerind commented 1 year ago

No. It's all good from what I can tell.