Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[web] instantiateImageCodecWithSize hardcodes allowUpscaling: false, breaking ResizeImage(allowUpscaling: true)

未关闭 适合新手
#195,193 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@sankalpsthakur 已经在做这个了。

开始于 2026年10月26日。

  • #1 来自 @sankalpsthakur —— 已关闭,未合并
  • #195344 来自 @sankalpsthakur —— 已关闭,未合并
  • #195346 来自 @sankalpsthakur —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
dart, flutter, web-dev

调研方向

阅读 engine/src/flutter/lib/web_ui/lib/painting.dart 中 instantiateImageCodecWithSize 附近的代码以及相关的 getTargetSize 调用。然后移除 packages/flutter/test/painting/image_provider_resize_image_test.dart 中 ResizeImage 组周围针对浏览器的跳过逻辑,并运行 flutter test --platform chrome test/painting/image_provider_resize_image_test.dart。当 allowUpscaling: true 的测试用例在 Chrome 上以预期的图像尺寸通过时,即为完成。

由索引模型根据 Issue 内容生成。

描述

P2 team-web triaged-web
Description

In engine/src/flutter/lib/web_ui/lib/painting.dart, instantiateImageCodecWithSize invokes getTargetSize(width, height) (where ResizeImage has already enforced its own allowUpscaling parameter) and then passes a hardcoded allowUpscaling: false to engine.engineInstantiateImageCodec:

final TargetImageSize targetSize = getTargetSize(width, height);
return await engine.engineInstantiateImageCodec(
  buffer._list!,
  targetWidth: targetSize.width,
  targetHeight: targetSize.height,
  allowUpscaling: false,
);

On native (dart:ui), instantiateImageCodecWithSize scales to whatever TargetImageSize is returned by getTargetSize, leaving upscaling policy to the caller (ResizeImage.allowUpscaling). Because the web implementation hardcodes allowUpscaling: false, ResizeImage(..., allowUpscaling: true) clamps target dimensions back down to the intrinsic image size on web.

Note: packages/flutter/test/painting/image_provider_resize_image_test.dart (line 622) still skips its ResizeImage group on isBrowser referencing closed #73120.

Steps to Reproduce
  1. Remove skip: isBrowser on line 622 of packages/flutter/test/painting/image_provider_resize_image_test.dart.
  2. Run:
    flutter test --platform chrome test/painting/image_provider_resize_image_test.dart
    
Expected Results

All ResizeImage tests pass on Chrome (both CanvasKit and Skwasm), upscaling images when allowUpscaling: true is specified.

Actual Results

16 allowUpscaling: true test cases fail because the decoded ui.Image remains at its intrinsic dimensions instead of scaling up to the size returned by getTargetSize.

主要语言
Dart
星标
180k
派生
33.9k
平均合并
1 天 22 小时
30 天内合并 PR
281

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

flutter/flutter 的其他 Issue

查看 flutter/flutter 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。