Skip to content

Inlined assets with fractional scales resolve to the wrong variant #1504

Open

Description

@RaphaelFakhri

Description

With inline: true in the assets loader, an image that has a fractional scale variant (@0.75x or @1.5x) resolves to the wrong scale at runtime.

inlineAssets passes Object.keys(sourceSet).map(Number) to AssetSourceResolver.pickScale. Integer-like object keys are listed before other keys, so [0.75, 1, 1.5, 2, 3] becomes [1, 2, 3, 0.75, 1.5]. pickScale expects an ascending list ("Packager guarantees that scales array is sorted").

Reproduction

  1. Add star@1x.png, star@1.5x.png, star@2x.png and star@3x.png.
  2. Enable inline: true for the Re.Pack assets loader and render require('./star.png').
  3. Run on an Android device with a pixel ratio of 3.5.

Expected: the @3x image. Actual: the @1.5x image. A pixel ratio of 1.5 gets @2x instead of @1.5x.

Environment

@callstack/repack main (5.4.2), any React Native version.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions