Skip to content

fix(wallpaper): Revoke blob URL only after new one is set#209

Merged
prem-k-r merged 3 commits into
mainfrom
wallpaper-blob-revocation
May 10, 2026
Merged

fix(wallpaper): Revoke blob URL only after new one is set#209
prem-k-r merged 3 commits into
mainfrom
wallpaper-blob-revocation

Conversation

@prem-k-r

@prem-k-r prem-k-r commented May 7, 2026

Copy link
Copy Markdown
Owner

Fixed wallpaper disappearing on load due to blob URL being revoked too early

Closes #169
Supersedes #206

Overview

This PR fixes a bug where wallpapers could disappear on load because a background blob URL was revoked too early. The change ensures the old object URL is revoked only after a new one has been created and applied, preventing the race condition that made wallpaper images unavailable. This closes issue #169 and supersedes PR #206.

Changes

scripts/wallpaper.js

  • Added module-level currentBgUrl to track the active background object URL.
  • Introduced setBackground(blob) helper that:
    • Creates a new object URL, applies it to --bg-image and data-bg, then revokes the previous object URL (revocation occurs after the new URL is set).
    • Updates currentBgUrl.
  • Refactored all background-setting flows (user uploads, fetched random images, and IndexedDB restoration) to use setBackground() instead of creating ad-hoc URL.createObjectURL and manually revoking URLs.
  • Random-image fetch flow now converts responses to blobs, saves them to IndexedDB, and applies them via setBackground() (removed previous delayed-revocation logic).
  • On restore from IndexedDB, applies stored blobs via setBackground() and re-fetches daily random images when the stored timestamp is not from the current day.
  • Clear-background flow now revokes and nulls currentBgUrl before removing the --bg-image CSS property and switching to color mode.
  • Minor reordering of listener wiring and the initial checkAndUpdateImage() call to align with the refactored lifecycle.

CHANGELOG.md

  • Added an [Unreleased] → Fixed entry documenting the wallpaper disappearance fix.

manifest.json / manifest(firefox).json

  • No version bump in these files in this branch (both remain at 3.3.504 in the repository snapshot).

style.css

  • Added placeholder styling rule for inputs in shortcut settings: .shortcutSettingsEntry input::placeholder.
  • Adjusted spacing for .shortcutInputRow:last-child.

Problem Solved

Fixes issue #169: prevents automatic removal of user-set wallpapers by ensuring object URLs are revoked only after a new background has been applied. Wallpapers should now persist across browser sessions and days until changed by the user or the extension is reset/uninstalled.

Impact

  • No exported/public API changes; changes are internal to the wallpaper lifecycle management.
  • Review effort: Medium (behavior-critical fix affecting image lifecycle, persistence, and IndexedDB interactions).

@prem-k-r prem-k-r added the bugfix Fixes existing bugs or regressions label May 7, 2026
@coderabbitai

This comment was marked as spam.

@prem-k-r prem-k-r requested a review from itz-rj-here May 7, 2026 04:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/wallpaper.js`:
- Around line 19-25: The function setBackground currently revokes currentBgUrl
before creating and applying the new object URL, risking loss of the background
if creation or application fails; change the order in setBackground so you first
call URL.createObjectURL(blob) to get newUrl, apply it via
document.body.style.setProperty("--bg-image", `url(${newUrl})`) and update
currentBgUrl, and only after successful creation/application call
URL.revokeObjectURL on the old currentBgUrl (using the existing currentBgUrl
variable), ensuring you reference the same identifiers (setBackground,
currentBgUrl, URL.createObjectURL, URL.revokeObjectURL,
document.body.style.setProperty).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9b8dc2b7-af6c-4d02-8585-dfaf4e68488e

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf4e03 and 17dc709.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • scripts/wallpaper.js

Comment thread scripts/wallpaper.js
@prem-k-r prem-k-r added the under-review Currently being reviewed. Please wait for feedback. label May 7, 2026
@prem-k-r prem-k-r force-pushed the wallpaper-blob-revocation branch from e56cc96 to db964a3 Compare May 10, 2026 17:33
@prem-k-r prem-k-r merged commit 120dfb3 into main May 10, 2026
3 checks passed
@prem-k-r prem-k-r deleted the wallpaper-blob-revocation branch May 10, 2026 18:51
@prem-k-r prem-k-r removed the under-review Currently being reviewed. Please wait for feedback. label May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes existing bugs or regressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Wallpaper automatically gets removed after some days

2 participants