Skip to content

Stop crashing when a widget is removed from the home screen - #73

Merged
hameno merged 1 commit into
masterfrom
feature/fix_widget_delete_crash
Oct 10, 2026
Merged

hameno merged 1 commit into
masterfrom
feature/fix_widget_delete_crash

Conversation

@hameno

@hameno hameno commented Oct 10, 2026

Copy link
Copy Markdown
Member

Removing a widget crashed the app on every 3.0 build (beta 3.0.0-198 included; production 2.1 is not affected):

NullPointerException: ... BroadcastReceiver$PendingResult.finish() on a null object reference
    at DDWidgetProvider$onDeleted$2.invokeSuspend(DDWidgetProvider.kt:37)

GlanceAppWidgetReceiver.onDeleted already takes the broadcast's goAsync(), so the provider's second goAsync() returned null. The provider now leaves the broadcast to Glance and queues CleanupWidgetsWorker, which deletes the records of widgets no longer on the home screen.

Also fixed: the startup cleanup never ran, because its one-off work shared the unique name of the periodic work, whose REPLACE policy cancelled it.

Verified on an emulator: removing a widget crashed the old build and doesn't crash the fixed one, and the cleanup runs. New Robolectric tests (with androidx.work:work-testing) cover both cases.

🤖 Generated with Claude Code

Since the move to Glance, GlanceAppWidgetReceiver.onDeleted takes the
broadcast's goAsync() itself, so DDWidgetProvider's own goAsync() returned
null and finishing it crashed the app every time a widget was removed. The
provider now leaves the broadcast to Glance and queues CleanupWidgetsWorker,
which deletes the records of widgets no longer on the home screen.

The startup cleanup was never run either: its one-off work shared the unique
name of the periodic work, whose REPLACE policy cancelled it. It now has its
own name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hameno
hameno enabled auto-merge October 10, 2026 19:46
@github-actions

Copy link
Copy Markdown

Test Results

126 tests  +2   126 ✅ +2   35s ⏱️ +6s
 34 suites +1     0 💤 ±0 
 34 files   +1     0 ❌ ±0 

Results for commit c428d94. ± Comparison against base commit c4d777c.

@hameno
hameno merged commit 6220e6b into master Oct 10, 2026
2 checks passed
@hameno
hameno deleted the feature/fix_widget_delete_crash branch October 10, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant