Skip to content

fix: [SDK-5120] inline the icon unless it is the notification image - #1561

Merged
sherwinski merged 2 commits into
mainfrom
sherwin/sdk-5120
Nov 6, 2026
Merged

sherwinski merged 2 commits into
mainfrom
sherwin/sdk-5120

Conversation

@sherwinski

Copy link
Copy Markdown
Contributor

Description

1 Line Summary

Inline the notification icon unless the icon is the notification image. Follow-up to #1531.

Details

#1531 inlines the icon so Chrome on Android does not show the grey "W" placeholder when the icon fetch fails. For a push with an image, the worker only inlined the icon when it was equal to the stored app default icon (Options.defaultIcon). That check skipped the inline path in 3 cases:

  1. The device has no Options.defaultIcon. Only a page load writes that record, so a device that did not open the site since the release never inlines an icon on a push with an image.
  2. The payload icon and the app config defaultIconUrl differ in any character.
  3. The push has a per-notification chrome_web_icon. The icon is a real icon, not the image, and it was passed through as a URL.

The Sun sends most pushes from a template with a global image, so the reports in SDK-5120 that continue after the 160700 release fall in these cases.

The intent of the check was Chrome on macOS, where the server sets the icon to the notification image. This change asks that question directly: the icon passes through as a URL only when it is equal to notification.image. Everything else is inlined. Options.defaultIcon still fills in a missing icon, but it no longer decides the inline path.

Known limit: if the macOS payload drops image after the server sets the icon to the image URL, the worker tries to inline that URL. The current code on main does the same in that case. inlineImage has a 5 s timeout and a 128 KB cap, so a large image falls back to the remote URL.

Systems Affected

  • WebSDK
  • Backend
  • Dashboard

Validation

Tests

Info

  • vp test src/sw/serviceWorker/ServiceWorker.test.ts src/sw/helpers/inlineImage.test.ts: 59 passed.
  • vp check: 0 errors. The 7 warnings are in OneSignal.test.ts and exist on main.
  • vp run build:prod: size-limit passes. Worker bundle 13.06 kB (limit 13.1 kB), page bundle unchanged.

Test changes in ServiceWorker.test.ts, under "with the flag and a large image":

  • "leaves a per-notification icon as a remote URL" is now "inlines a per-notification icon" and checks that the image URL is not fetched.
  • New: "inlines the icon when the device has no stored default icon".
  • Unchanged: the app default icon is inlined with and without a payload icon, and an icon equal to the image is passed through.

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

Not needed. The change is a 1 line condition in the worker with unit tests for each branch.

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets

The worker skipped the inline path for any push with an image when the
icon was not the stored app default icon. That check failed when the
device had no stored default icon or when the payload icon did not match
the app config. Compare the icon with the image instead, so only the
server-set image icon on Chrome for macOS passes through as a URL.

@abdulraqeeb33 abdulraqeeb33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The icon is inlined unless it is the notification image. The comparison runs after both URLs are rewritten to HTTPS, so an icon the server set to the image still matches. A missing icon still falls back to the stored default, and that default no longer decides the inline path.

The new tests cover a distinct icon and a device with no stored default. The image URL is not fetched in those cases.

@fadi-george fadi-george left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, a couple of non-blocking notes inline.

Comment thread src/sw/serviceWorker/ServiceWorker.ts Resolved
Comment thread src/sw/serviceWorker/ServiceWorker.ts Resolved
@sherwinski
sherwinski merged commit 45b121e into main Nov 6, 2026
1 check passed
@sherwinski
sherwinski deleted the sherwin/sdk-5120 branch November 6, 2026 23:17
@github-actions github-actions Bot mentioned this pull request Nov 10, 2026
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.

3 participants