Skip to content

[web] on webOS devicePixelRatio returns 0 #48303

@csnewman

Description

@csnewman

On some platforms, such webOS, the window.devicePixelRatio returns 0. This causes the likes of BitmapCanvas to have a size of 2 width * 0 + 2 * kPaddingPixels. Meaning anything requiring a bitmap canvas to render won't.

Steps to Reproduce

  1. Download flutter_gallery example app
  2. Add <script> window.devicePixelRatio = 0.0; </script> to head in web/index.html
  3. Run flutter run -d chrome

Input will be broken and rendering will have some issues (you'll need to set the pixel ratio to use input). Rendering will be dependent upon if the component uses BitmapCanvas.

Attempting to use window.devicePixelRatio = 1.0 (which is then read by html.window.devicePixelRatio inside dart), sadly doesn't work on webOS, and the value will still read as 0. Some way of being able to override the devicePixelRatio would be useful, or atleast falling back to 1, if a value of 0 is returned.

Target Platform: Web
Target OS version/browser: Chrome
Devices: Linux desktop, and also on webOS 4.0 emulator
webOS chrome version: "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.34 Safari/537.36 WebAppManager"
Desktop chrome version: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"

[✓] Flutter (Channel master, v1.13.7-pre.41, on Linux, locale en_GB.UTF-8)
    • Flutter version 1.13.7-pre.41 at /home/csnewman/development/flutter
    • Framework revision fa337f5922 (15 hours ago), 2020-01-06 16:44:12 -0800
    • Engine revision 3851981b86
    • Dart version 2.8.0 (build 2.8.0-dev.0.0 2f57602411)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    • Android SDK at /home/csnewman/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.0
    • Java binary at: /home/csnewman/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.6010548/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[!] Android Studio (version 3.5)
    • Android Studio at /home/csnewman/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.6010548
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (2 available)
    • Chrome     • chrome     • web-javascript • Google Chrome 77.0.3865.90
    • Web Server • web-server • web-javascript • Flutter Tools

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

Labels

dependency: dartDart team may need to help use: device-specificOnly manifests on certain devicesengineflutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.platform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions