Images fails to load the second time on web when compiled to wasm
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
使用 lib/main.dart 中的示例重现该问题,并使用 flutter run -d chrome --wasm 运行。比较有无 errorListener 时的导航序列;在不提供 errorListener 的情况下返回并重新打开页面后图像再次加载,即表示完成。
由索引模型根据 Issue 内容生成。
描述
🐛 Bug Report
When compiled to wasm, images don't load the second time if navigated back and forth again, giving the below error:
ImageCodecException: Failed to decode image using the browser's ImageDecoder API.
Image source: https://docs.flutter.dev/assets/images/dash/dash-fainting.gif
Original browser error: JavaScriptError
But, if you provide the errorListener param some value, this error mysteriously fixes.
Expected behavior
Images should load every time without giving any errors even if errorListener is not provided.
Reproduction steps
- Copy below sample code into
lib/main.dart - Run on web with wasm using the below command:
flutter run -d chrome --wasm - Click on
Open Page 1button and wait for the image to load - Click back and wait 5 seconds
- Once again click
Open Page 1button - See image loading error
- Now uncomment the
errorListenerline in sample code - Enter
rin terminal to hot restart - Repeat steps 3-5
- See the error is fixed magically
Configuration
Version: 3.4.1
Platform:
- 📱 iOS
- 🤖 Android
- 🕸️ Web
Additional Data
Sample Code
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _urls = [
'https://docs.flutter.dev/assets/images/dash/dash-fainting.gif',
'https://picsum.photos/250?image=2',
];
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Web Images',
home: Builder(
builder: (context) {
return Scaffold(
appBar: AppBar(title: Text('Web Images')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () => _onPressed(context, 0),
child: Text('Open Page 1'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () => _onPressed(context, 1),
child: Text('Open Page 2'),
),
],
),
),
);
},
),
);
}
void _onPressed(BuildContext context, int index) {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => NewWidget(url: _urls[index])),
);
}
}
class NewWidget extends StatelessWidget {
const NewWidget({super.key, required this.url});
final String url;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: CachedNetworkImage(
imageUrl: url,
placeholder: (_, _) => CircularProgressIndicator.adaptive(),
// ! Uncomment the line below to see magic
// errorListener: (_) {},
),
),
);
}
}
- 主要语言
- Dart
- 星标
- 2.6k
- 派生
- 734
- 平均合并
- 3 天 10 小时
- 30 天内合并 PR
- 14
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Baseflow/flutter_cached_network_image 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
Baseflow/flutter_cached_network_image#492 · 2 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
Baseflow/flutter_cached_network_image#478 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
Baseflow/flutter_cached_network_image#473 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
Baseflow/flutter_cached_network_image#1032 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
Baseflow/flutter_cached_network_image#1031 ·
维护者通常 1 天内回复
查看 Baseflow/flutter_cached_network_image 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
google/skills_lint.dart#58 ·
维护者通常 1 天内回复
-
P2 status: first-line-handled type: bug
难度 2/5 1-3 小时 新手友好度 78/100
a2ui-project/a2ui#2871 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
genkit-ai/genkit-dart#507 ·
维护者通常 4 天内回复
-
infra: device lab team-android
难度 2/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
google/webcrypto.dart#419 ·
维护者通常 4 天内回复