Skip to content

Image.network Widget with cacheWidth/cacheHeight smaller than the image displays black #158093

Closed
flutter-team-archive/engine
#57200

Description

@michaelheider

Steps to reproduce

  1. Build app for web.
  2. Access with a web browser.

If cacheWidth = cacheHeight = 30 (which is smaller than the 40px image size), the page will display a black square of the correct size instead of the image.

If cacheWidth = cacheHeight = 50 (which is larger or equal than the 40px image size), the page will display the image correctly. it also works if both are null.

Pitfalls avoided: Make sure the image you use for testing exists (i.e. you can open it in your browser). Ensure the image has permissive CORS headers (no CORS errors in browser console).

Expected results

The image displays properly no matter the values of cacheWidth and cacheHeight.

Actual results

If cacheWidth or cacheHeight are smaller than the image's pixel dimensions, then the image does not display, an all-black placeholder of the correct size is displayed instead.

No error messages or special logs.

Code sample

Code sample
import 'package:flutter/widgets.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Image.network(
      cacheWidth: 30,
      cacheHeight: 30,
      'https://fastly.picsum.photos/id/505/40/40.jpg?hmac=egB4BZLkmlPCkk32_xTVvQg2I8QZH2w369evjD3Q1Pk',
    );
  }
}

Flutter Doctor output

Doctor output
[✓] Flutter (Channel beta, 3.27.0-0.1.pre, on Ubuntu 22.04.5 LTS 6.8.0-48-generic, locale en_US.UTF-8)
    • Flutter version 3.27.0-0.1.pre on channel beta at /home/michael/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2e2c358c9b (13 days ago), 2024-10-22 11:02:13 -0400
    • Engine revision af0f0d559c
    • Dart version 3.6.0 (build 3.6.0-334.3.beta)
    • DevTools version 2.40.1

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /home/michael/Android/Sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /home/michael/Android/Sdk
    • Java binary at: /snap/android-studio/161/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

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

[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
    ✗ CMake is required for Linux development.
      It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from
      https://github.com/ninja-build/ninja/releases
    ✗ pkg-config is required for Linux development.
      It is likely available from your distribution (e.g.: apt install pkg-config), or can be downloaded from
      https://www.freedesktop.org/wiki/Software/pkg-config/

[✓] Android Studio (version 2024.1)
    • Android Studio at /snap/android-studio/161
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)

[✓] VS Code (version 1.95.1)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.100.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.5 LTS 6.8.0-48-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 130.0.6723.91

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. added
    in triage
    on Nov 4, 2024
  2. huycozy commented on Nov 4, 2024

    @huycozy
    Member

    I can reproduce the issue on Flutter beta and master channels. On Flutter stable 3.24.4, the issue does not appear. Marking this as a regression.

    Also, I see this appears on Web app only, does not appear on Android or macOS apps.

    Flutter versions (stable and master)
    [✓] Flutter (Channel stable, 3.24.4, on macOS 15.0.1 24A348 darwin-x64, locale en-VN)
        • Flutter version 3.24.4 on channel stable at /Users/huynq/Documents/GitHub/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 603104015d (12 hours ago), 2024-10-24 08:01:25 -0700
        • Engine revision db49896cf2
        • Dart version 3.5.4
        • DevTools version 2.37.3
    [!] Flutter (Channel master, 3.27.0-1.0.pre.350, on macOS 15.0.1 24A348 darwin-x64, locale en-VN)
        • Flutter version 3.27.0-1.0.pre.350 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision a1fbc839e2 (56 minutes ago), 2024-11-04 09:47:30 +0800
        • Engine revision 05cb5d7f79
        • Dart version 3.7.0 (build 3.7.0-95.0.dev)
        • DevTools version 2.40.1
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
  3. added
    c: regression
    platform-web
    a: images
    has reproducible steps
    team-web
    found in release: 3.27
    and removed
    in triage
    on Nov 4, 2024
  4. added
    P2
    triaged-web
    on Nov 7, 2024
  5. Reprevise commented on Dec 11, 2024

    @Reprevise

    How is this not a P1 regression issue? Flutter 3.27 has landed in stable today and all of the images on our web app are broken because we make use of the cacheX parameters.

  6. Reprevise commented on Dec 13, 2024

    @Reprevise

    This is easily reproducable on all branches of Flutter (main, beta, and now stable).

    @yjbanov Can you reconsider this issue's priority since 3.27 has landed in stable?

  7. self-assigned this
    on Dec 16, 2024
  8. added
    P1
    and removed
    P2
    on Dec 16, 2024
  9. added
    r: fixed
    on Dec 17, 2024
  10. github-actions commented on Dec 31, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  11. locked as resolved and limited conversation to collaborators on Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1a: imagesc: regressionfound in release: 3.27has reproducible stepsplatform-webr: fixedteam-webtriaged-web

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions