webf
webf copied to clipboard
Exception: Invalid image data
Affected version
^0.13.2+1
No same issues found.
- [X] Yes, I search all issues but not found.
Steps to Reproduce
1、我用webf写了一个关于页面,代码里面有两张图片,一种是img标签引入,一张是背景图片 2、背景图片引入的图片,第一次打开可以访问,第二次打开就会报错 3、当把背景图片改成,img标签使用的时候,又没有问题,我感觉是 background-image 有问题,第一次引入不走缓存直接访问nginx,就没问题,第二次走缓存,没有请求nginx的时候,就会出问题,img 标签每次都会走nginx,所以没问题,但是我需要用背景图片来实现这个功能,搞不了
Code example
about.vue
<div class="header" style="padding: 140rpx 24rpx 0;
background-size: 100%;
height: 456rpx;
background-repeat: no-repeat;" :style="{backgroundImage: 'url(' + bgImg + ')'}">
<div class="uni-flex uni-column appinfo" style="display: flex; flex-direction: column; text-align: center;">
<div>
<img src="@/static/icons/用户中心/logo2.png" style="height: 160rpx; width: 160rpx; border-radius: 10rpx; " />
</div>
<div class="uni-flex uni-column" style="display: flex; flex-direction: column; flex: 1">
<span class="name" style="font-size: 32rpx;
font-weight: 400;
color: rgba(0,0,0,0.90);
margin-top: 28rpx;"></span>
<span class="txt" style="font-size: 20rpx;
font-weight: 400;
color: rgba(0,0,0,0.30);
line-height: 36rpx;">版本号:{{ version }}</span>
</div>
</div>
</div>
import {ref} from 'vue'
import {getVersion, navigateTo} from "../../common/webf";
import bgImg from '@/static/icons/用户中心/header-bg.png'
Expected results
div 背景图片可以不走缓存,或者走缓存也不会报错
Actual results
nginx log
192.168.1.42 - - [07/Feb/2023:06:57:27 +0000] "GET /static/webf/about.js?t=1675753046 HTTP/1.1" 200 25266 "http://192.168.1.21:9080/static/webf/about.js?t=1675753046" "WebF/0.13.2+1 (android; WebF/b927790)" "-"
192.168.1.42 - - [07/Feb/2023:06:57:27 +0000] "GET /static/webf/assets/logo2.ff756a94.png HTTP/1.1" 200 4977 "http://192.168.1.21:9080/static/webf/about.js?t=1675753046" "WebF/0.13.2+1 (android; WebF/b927790)" "-"
192.168.1.42 - - [07/Feb/2023:06:57:28 +0000] "GET /static/webf/assets/header-bg.705b0b56.png HTTP/1.1" 200 119002 "-" "Dart/2.18 (dart:io)" "-"
192.168.1.42 - - [07/Feb/2023:06:57:45 +0000] "GET /static/webf/about.js?t=1675753066 HTTP/1.1" 200 25266 "http://192.168.1.21:9080/static/webf/about.js?t=1675753066" "WebF/0.13.2+1 (android; WebF/b927790)" "-"
192.168.1.42 - - [07/Feb/2023:06:57:45 +0000] "GET /static/webf/assets/logo2.ff756a94.png HTTP/1.1" 200 4977 "http://192.168.1.21:9080/static/webf/about.js?t=1675753066" "WebF/0.13.2+1 (android; WebF/b927790)" "-"
flutter log
E/FlutterJNI(23767): Failed to decode image
E/FlutterJNI(23767): android.graphics.ImageDecoder$DecodeException: Failed to create image decoder with message 'unimplemented'Input contained an error.
E/FlutterJNI(23767): at android.graphics.ImageDecoder.nCreate(Native Method)
E/FlutterJNI(23767): at android.graphics.ImageDecoder.access$200(ImageDecoder.java:169)
E/FlutterJNI(23767): at android.graphics.ImageDecoder$ByteBufferSource.createImageDecoder(ImageDecoder.java:246)
E/FlutterJNI(23767): at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1760)
E/FlutterJNI(23767): at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1753)
E/FlutterJNI(23767): at io.flutter.embedding.engine.FlutterJNI.decodeImage(FlutterJNI.java:524)
======== Exception caught by image resource service ================================================
The following _Exception was thrown resolving an image codec:
Exception: Invalid image data
When the exception was thrown, this was the stack:
#0 _futurize (dart:ui/painting.dart:5886:5)
#1 ImageDescriptor.encoded (dart:ui/painting.dart:5741:12)
#2 instantiateImageCodecFromBuffer (dart:ui/painting.dart:2092:60)
#3 instantiateImageCodec (dart:ui/painting.dart:2050:10)
<asynchronous suspension>
Image provider: CachedNetworkImage()
Image key: Instance of 'CachedNetworkImageKey'
====================================================================================================
试了很多各种配置,最后发现是 nginx 开启了gzip,当开启gzip的时候,CachedNetworkImage 会报错,我把nginx的gzip关了,就可以没问题
诶,竟然和 gzip 有关,我看看