Skip to content

Conversation

@patmmccann
Copy link
Collaborator

No description provided.

patmmccann and others added 2 commits November 20, 2025 17:13
@github-actions
Copy link

Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:

Reducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀

@github-actions
Copy link

Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:

Reducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀

@patmmccann
Copy link
Collaborator Author

duplication solved here #14186

@patmmccann patmmccann marked this pull request as ready for review November 24, 2025 22:19
@patmmccann patmmccann changed the title Various adapters: consolidate devicepixelratio usage Various adapters: consolidate devicepixelratio usage into approximation Nov 24, 2025
@github-actions
Copy link

Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:

Reducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀

@github-actions
Copy link

Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:

Reducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀

Copy link
Collaborator

@dgirardi dgirardi left a comment

Choose a reason for hiding this comment

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

I pushed an update about the code itself, but I'm not convinced the approximation works:

  • the fallback using screen.height / innerHeight is way off for me (dpr = 1, approx ~= 5.5)
  • screen.width / innerWidth kinda works (1 vs 1.02) but only if the browser window is maximized. Resizing it changes the approximated value significantly while devicePixelRatio remains constant
  • I know very little about devicePixelRatio but I suspect it would behave differently on mobile.

@dgirardi
Copy link
Collaborator

I missed some unit tests that would need to be updated to work with this, but I'll wait to see what we want to do before addressing them

@dgirardi
Copy link
Collaborator

dgirardi commented Dec 3, 2025

I updated this to keep the centralization but just return devicePixelRatio, pending separate work to gate it (and others) behind publisher config


export function getDevicePixelRatio(win) {
try {
return getFallbackWindow(win).devicePixelRatio;

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91

function getScreenParams() {
return `${window.screen.width}x${window.screen.height}@${window.devicePixelRatio}`;
return `${window.screen.width}x${window.screen.height}@${getDevicePixelRatio(window)}`;

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
'wxo': win.pageXOffset,
'wyo': win.pageYOffset,
'wpr': win.devicePixelRatio,
'wpr': getDevicePixelRatio(win),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
deviceWidth: screen.width,
deviceHeight: screen.height,
devicePixelRatio: topWindow.devicePixelRatio,
devicePixelRatio: getDevicePixelRatio(topWindow),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
tpl: mosttopURL,
ce: storage.cookiesAreEnabled(),
dpr: topWindow.devicePixelRatio || 1,
dpr: getDevicePixelRatio(topWindow),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
const uuid = uids[0] ? uids[0] : generateTemporaryUUID();
const floor = getBidFloor(request, request.sizes || []);
const dpr = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
const dpr = typeof window !== 'undefined' ? getDevicePixelRatio(window) : 1;

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
const req = buildRequest(imps, bidderRequest, context);
req.tmax = DEFAULT_TIMEOUT;
deepSetValue(req, 'device.pxratio', window.devicePixelRatio);
deepSetValue(req, 'device.pxratio', getDevicePixelRatio(getWindowContext()));

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
'CH-Downlink': connection.downlink,
'CH-DeviceMemory': null,
'CH-Dpr': W.devicePixelRatio,
'CH-Dpr': getDevicePixelRatio(W),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
deviceWidth: screen.width,
deviceHeight: screen.height,
devicePixelRatio: topWindow.devicePixelRatio,
devicePixelRatio: getDevicePixelRatio(topWindow),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting

devicePixelRatio is an indicator of fingerprinting; weight: 18.91

export function getDevicePixelRatio(win) {
try {
return getFallbackWindow(win).devicePixelRatio;

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting Warning

devicePixelRatio is an indicator of fingerprinting; weight: 18.91

function getScreenParams() {
return `${window.screen.width}x${window.screen.height}@${window.devicePixelRatio}`;
return `${window.screen.width}x${window.screen.height}@${getDevicePixelRatio(window)}`;

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting Warning

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
deviceWidth: screen.width,
deviceHeight: screen.height,
devicePixelRatio: topWindow.devicePixelRatio,
devicePixelRatio: getDevicePixelRatio(topWindow),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting Warning

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
tpl: mosttopURL,
ce: storage.cookiesAreEnabled(),
dpr: topWindow.devicePixelRatio || 1,
dpr: getDevicePixelRatio(topWindow),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting Warning

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
const uuid = uids[0] ? uids[0] : generateTemporaryUUID();
const floor = getBidFloor(request, request.sizes || []);
const dpr = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
const dpr = typeof window !== 'undefined' ? getDevicePixelRatio(window) : 1;

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting Warning

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
const req = buildRequest(imps, bidderRequest, context);
req.tmax = DEFAULT_TIMEOUT;
deepSetValue(req, 'device.pxratio', window.devicePixelRatio);
deepSetValue(req, 'device.pxratio', getDevicePixelRatio(getWindowContext()));

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting Warning

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
'CH-Downlink': connection.downlink,
'CH-DeviceMemory': null,
'CH-Dpr': W.devicePixelRatio,
'CH-Dpr': getDevicePixelRatio(W),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting Warning

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
deviceWidth: screen.width,
deviceHeight: screen.height,
devicePixelRatio: topWindow.devicePixelRatio,
devicePixelRatio: getDevicePixelRatio(topWindow),

Check warning

Code scanning / CodeQL

Use of browser API associated with fingerprinting Warning

devicePixelRatio is an indicator of fingerprinting; weight: 18.91
@patmmccann patmmccann removed the request for review from ncolletti December 3, 2025 19:00
@patmmccann
Copy link
Collaborator Author

marking as on hold for next pmc, we didnt cover today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants