Bug Report: "Keep Screen On" Feature Not Working When Pre-meditation Delay is Disabled
Environment
- App Version: 1.5.0+17
- Platform: Android
- Flutter Version: 3.5.3+
- Device: Redmi Note 10 Pro
Bug Description
The "Keep Screen On" setting does not work when the "Pre-meditation delay" option is disabled. The screen turns off after approximately 2 minutes of meditation, even when the "Keep Screen On" checkbox is enabled in settings.
Steps to Reproduce
- Open the app settings
- Enable "Keep Screen On" option
- Ensure "Pre-meditation delay" is disabled (unchecked)
- Start a meditation timer (any duration > 2 minutes)
- Wait for about 2 minutes
- Expected: Screen stays on throughout the meditation
- Actual: Screen turns off after ~2 minutes
Root Cause Analysis
The issue is in the onMeditationStart() function in lib/timer.dart (lines 395-408).
Current problematic logic:
bool wakelockEnabled = await WakelockPlus.enabled;
if (Settings.getValue<bool>('screen-wakelock') == true) {
if (wakelockEnabled) {
// wakelock was already setup in onTimerStart
log.i('maintaining screen wakelock for meditation');
} else {
log.e('wakelock is not enabled but was supposed to be'); // ❌ Only logs error, doesn't enable wakelock
}
}
The problem:
- When "Pre-meditation delay" is disabled, the app skips
onTimerStart() and goes directly to onMeditationStart()
- In
onTimerStart(), wakelock is only enabled for the delay phase (line 364): WakelockPlus.enable();
- When there's no delay, wakelock is never enabled, so
wakelockEnabled remains false
- The current code only logs an error but doesn't actually enable the wakelock
When it works correctly:
- If "Pre-meditation delay" is enabled, wakelock gets enabled in
onTimerStart() during the delay phase
- Then
onMeditationStart() finds wakelock already enabled and maintains it
Proposed Fix
Replace the error logging with actual wakelock enablement:
bool wakelockEnabled = await WakelockPlus.enabled;
if (Settings.getValue<bool>('screen-wakelock') == true) {
if (wakelockEnabled) {
// wakelock was already setup in onTimerStart
log.i('maintaining screen wakelock for meditation');
} else {
// enable wakelock if user has enabled "Keep Screen On" but wakelock isn't active
log.i('enabling screen wakelock for meditation');
WakelockPlus.enable(); // ✅ Actually enable wakelock
}
} else {
if (wakelockEnabled) {
log.i('disabling screen wakelock for meditation');
WakelockPlus.disable();
}
}
Impact
- Severity: Medium - Core functionality doesn't work in common usage scenario
- Users Affected: All users who enable "Keep Screen On" but don't use "Pre-meditation delay"
- Workaround: Enable "Pre-meditation delay" as a temporary workaround
Bug Report: "Keep Screen On" Feature Not Working When Pre-meditation Delay is Disabled
Environment
Bug Description
The "Keep Screen On" setting does not work when the "Pre-meditation delay" option is disabled. The screen turns off after approximately 2 minutes of meditation, even when the "Keep Screen On" checkbox is enabled in settings.
Steps to Reproduce
Root Cause Analysis
The issue is in the
onMeditationStart()function inlib/timer.dart(lines 395-408).Current problematic logic:
The problem:
onTimerStart()and goes directly toonMeditationStart()onTimerStart(), wakelock is only enabled for the delay phase (line 364):WakelockPlus.enable();wakelockEnabledremainsfalseWhen it works correctly:
onTimerStart()during the delay phaseonMeditationStart()finds wakelock already enabled and maintains itProposed Fix
Replace the error logging with actual wakelock enablement:
Impact