Notification creation fails with SVG in iconUrl

201 views
Skip to first unread message

Hossan Mohammad Zubayer

unread,
Mar 22, 2024, 1:10:28 PM3/22/24
to Chromium Extensions
Hello creating a notification with an SVG in iconUrl fails with
  Unable to download all specified images
 
  specifically DOMException: The source image could not be decoded.
 
     var price = 12;
    chrome.notifications.create({
        type: 'basic',
        iconUrl: "data:image/svg+xml;utf8,<svg width='128' height='128' viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg' version='1.1' > <text text-anchor='middle' x='50%' y='50%' dy='.35em' font-family='sans-serif' font-size='80px' font-weight='bold' fill='darkorange'>"+price+"</text></svg>",
        title: "This is the title",
        message: "This is the body of message",
        priority: 2,
    });
This piece of code works in MV2. Does anyone know a solution to this problem or have an SVG example that works in iconUrl

wOxxOm

unread,
Mar 22, 2024, 3:49:34 PM3/22/24
to Chromium Extensions, Hossan Mohammad Zubayer
I guess it's because MV3 uses a service worker which can't parse DOM, which is required to render SVG icons. You can convert it to a PNG data URI inside the offscreen document using standard DOM methods based on Image+Canvas, then use the result in the service worker. Enjoy your "moving the platform forward" as advertised by MV3 team.

Jackie Han

unread,
Mar 22, 2024, 6:44:16 PM3/22/24
to wOxxOm, Chromium Extensions, Hossan Mohammad Zubayer
I reported this bug in August 2022 : https://issues.chromium.org/issues/40235125
wOxxOm commented on the bug too.
Current status of the bug is still "New" (was: Available).

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b4c1372c-2d3e-44f6-b2b2-708de65000d2n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages