Skip to content

Prebid Mobile: makes creative size transformation based on pxRatio.#4510

Open
mdanylov-sigma wants to merge 1 commit into
prebid:masterfrom
mdanylov-sigma:feature/mobile-creative-size-transformation
Open

Prebid Mobile: makes creative size transformation based on pxRatio.#4510
mdanylov-sigma wants to merge 1 commit into
prebid:masterfrom
mdanylov-sigma:feature/mobile-creative-size-transformation

Conversation

@mdanylov-sigma
Copy link
Copy Markdown

Description

Fixes #4501

Prebid Server was not converting device.w/device.h from physical pixels to device-independent pixels (DIPs) when generating the list of candidate sizes for interstitial ads. According to the OpenRTB spec, device.w/device.h represent physical screen pixels, while banner.format sizes are expected in DIPs. On high-density screens this caused standard mobile interstitial sizes (e.g. 320x480) to be absent from the generated format list.

This change adds opt-in pxratio conversion controlled by a new field ext.prebid.sdk.usepxratio. When set to true, device.w/device.h are divided by device.pxratio before being used to calculate the interstitial size bounds. Conversion is only applied when falling back to device dimensions — explicit banner.format sizes are left untouched.

Changes

  • Added usePxRatio (Boolean, JSON: usepxratio) field to ExtRequestPrebidSdk; added explicit of() factory overloads to preserve backward compatibility with existing callers
  • Added usePxRatio(BidRequest) helper to read the flag from ext.prebid.sdk
  • Added deviceSizeToDips(Integer, BigDecimal) helper: divides by pxratio using doubleValue(), rounds to nearest integer, clamps to minimum 1; returns size unchanged when size or pxratio is null or non-positive
  • Applied conversion in processInterstitialImp() only in the device-size fallback branch

Testing

  • processShouldReturnBidRequestUpdatedWithInterstitialFormatsUsingDeviceSizeInDipsWhenFormatIsEmpty — device 1080×1920 @ pxratio 3 → expects 320×480 in results
  • processShouldReturnBidRequestUpdatedWithInterstitialFormatsUsingDeviceSizeInDipsWhenFormatIsOneToOne — same, with 1×1 sentinel format
  • processShouldNotConvertExplicitFormatSizeUsingDevicePxratio — explicit banner format is not converted
  • processShouldKeepCurrentDeviceSizeBehaviorWhenUsePxRatioIsAbsent — no flag, no conversion (backward compatibility)
  • processShouldKeepCurrentDeviceSizeBehaviorWhenUsePxRatioIsTrueAndDevicePxRatioIsAbsent — flag set but pxratio missing, sizes unchanged

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.

Prebid Server doesn't transform device size to DPIs on calculating the creative sizes for Interstitial ads

1 participant