screen_brightness icon indicating copy to clipboard operation
screen_brightness copied to clipboard

[bug] Crash on android while background mode

Open wayupdev opened this issue 11 months ago • 9 comments

Description (bug summary)

Hello,

I have this crash on android that I can't reproduce on my side. Do you know where it could be coming from?

Image

Step to reproduce (how to reproduce the bug)

  1. Run the app in background mode
  2. Crash

Platform (Android/iOS/macOS/Windows)

Android

Crashlog : MethodChannelScreenBrightness.application io.flutter.plugins.firebase.crashlytics.FlutterError - PlatformException(-10, Unexpected error on activity binding, null, null)

wayupdev avatar Jan 22 '25 12:01 wayupdev

Hi @wayupdev, I cannot reproduce this crash with demo app. Are you crashing the with demo app? If so, what are the steps to reproduce it?

aaassseee avatar Jan 23 '25 12:01 aaassseee

Hi @aaassseee,

Sorry for the delay, on my side, I couldn't reproduce this crash on both app (demo and my own app). I only have the crashlytics report

wayupdev avatar Jan 25 '25 08:01 wayupdev

@wayupdev how do you use the plugin? Just light up when go to one page,?

aaassseee avatar Jan 25 '25 08:01 aaassseee

I use it in different way, in one part of my app, I have made a progressive brightness fonction like that :

double brightness = min(0.7, (info.currentTime.inSeconds / 5).floorToDouble() / 100); ScreenBrightness.instance.setApplicationScreenBrightness(brightness);

In some other part, I am just setting a value :

ScreenBrightness.instance.setApplicationScreenBrightness(0.1);

I also have a brightness.manager (where the issue seems to came from) :

import 'package:screen_brightness/screen_brightness.dart';

class BrightNessManager { static BrightNessManager manager = BrightNessManager(); late double brightness;

Future init() async { brightness = await ScreenBrightness.instance.application; } }

wayupdev avatar Jan 25 '25 09:01 wayupdev

@wayupdev Will it be possible when progressive brightness changing when user quit the application?

aaassseee avatar Jan 25 '25 10:01 aaassseee

Yes, I think the user puts the application in background and the package tries to modify the brightness without success, causing the crash.

wayupdev avatar Jan 25 '25 13:01 wayupdev

@wayupdev pausing the application should not cause this issue. Can you repeat this issue on your side?

aaassseee avatar Jan 25 '25 13:01 aaassseee

I'll try to reproduce it, and I'll keep you posted. Thanks for your help

wayupdev avatar Jan 25 '25 13:01 wayupdev

Sure. If it crash on pause, this is a critical issue.

aaassseee avatar Jan 25 '25 13:01 aaassseee