Skip to content

Fix Firefox "Alpha-premult deprecated for non-DOM uploads" warning (#2030)#7128

Merged
birkskyum merged 5 commits intomaplibre:mainfrom
birkskyum:premult
Feb 14, 2026
Merged

Fix Firefox "Alpha-premult deprecated for non-DOM uploads" warning (#2030)#7128
birkskyum merged 5 commits intomaplibre:mainfrom
birkskyum:premult

Conversation

@birkskyum
Copy link
Member

@birkskyum birkskyum commented Feb 13, 2026

Firefox logs a warning every time we ask WebGL to handle alpha premultiplication for raw pixel data (sprite atlases, color ramps, etc). It only wants us to use that WebGL flag for actual DOM elements like images and canvases For raw byte arrays, it expects us to do it ourselves.

This moves premultiplication into JS for raw data uploads, keeping the WebGL path for DOM elements.

Fixes #2030

Before

Screenshot 2026-02-13 at 21 46 45

After
Screenshot 2026-02-13 at 21 44 20

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

@birkskyum birkskyum requested a review from HarelM February 13, 2026 20:48
expect(texture.texture).toBe(originalHandle);
});

test('premultiplyAlpha produces correct output', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test needs to be next to its method, in image.test.ts or something...

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.63%. Comparing base (7776641) to head (babb46c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7128      +/-   ##
==========================================
+ Coverage   92.35%   92.63%   +0.27%     
==========================================
  Files         289      289              
  Lines       24017    24044      +27     
  Branches     5087     5089       +2     
==========================================
+ Hits        22181    22272      +91     
+ Misses       1836     1772      -64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@HarelM
Copy link
Collaborator

HarelM commented Feb 13, 2026

Thanks for this PR!
How confident are you about the performance of this? While I understand it might be good to resolve a Firefox warning, if this is worse for chrome, which is a lot more popular, I'm not sure it's worth it. What do you think?

@birkskyum
Copy link
Member Author

birkskyum commented Feb 14, 2026

As far as I can tell it should be fine. Firefox only optimizes the CPU path we're now using (JS premult), so they benefit. For Chrome, I ran the Paint benchmark comparing main vs this branch:

Screenshot 2026-02-14 at 15 03 05]

This branch is actually 3.4% faster (9.50ms vs 9.83ms) - ran it again and saw 2.9% improvement

Why minimal impact:

  • Texture uploads happen rarely (just at map load and style changes, not every frame)
  • We're processing tiny amounts of data: line gradients are 1KB, sprite atlases load once
  • Raster tiles (biggest perf factor) use images/canvas and aren't affected

@birkskyum birkskyum merged commit 52b7b60 into maplibre:main Feb 14, 2026
47 checks passed
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.

Firefox WebGL warning (Alpha-premult and y-flip are deprecated for non-DOM-Element uploads).

2 participants