LuckSiege / LuckSiege/PictureSelector

华为Android 10 EMUI 11 无法预览图片,选择图片长时间loading

Open
#1,946 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
13.6k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

华为Android 10 EMUI 11 无法预览图片,选择图片长时间loading,选择图片后长时间loading超过20s,有时甚至无法打开
引用代码
`
implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.1'
`
打开图片选择器代码
`
private boolean onShowFileChooser(WebView webView, ValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {

Activity activity = CommonUtil.getActivityFromContext(mContext);
if (CommonUtil.isActivityFinishing(activity)) return false;

int type = PictureMimeType.ofAll();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (fileChooserParams == null || fileChooserParams.getAcceptTypes() == null || fileChooserParams.getAcceptTypes().length <= 0) {
type = PictureMimeType.ofAll();
} else {
String accept = fileChooserParams.getAcceptTypes()[0].toLowerCase();
if (accept.startsWith("all")) {
type = PictureMimeType.ofAll();
} else if (accept.startsWith("image")) {
type = PictureMimeType.ofImage();
} else if (accept.startsWith("video")) {
type = PictureMimeType.ofVideo();
} else if (accept.startsWith("audio")) {
type = PictureMimeType.ofAudio();
}
}
}

PictureSelector.create(activity)
.openGallery(type)
.theme(R.style.picture_WeChat_style)
.isCompress(true)// 是否压缩
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
.imageEngine(GlideEngine.createGlideEngine())// 外部传入图片加载引擎,必传项
.loadCacheResourcesCallback(GlideCacheEngine.createCacheEngine())// 获取图片资源缓存,主要是解决华为10部分机型在拷贝文件过多时会出现卡的问题,这里可以判断只在会出现一直转圈问题机型上使用
.forResult(new OnResultCallbackListener() {

@Override
public void onResult(List result) {
ArrayList list = new ArrayList<>();
for (LocalMedia media : result) {
String path;
if (media.isCut() && !media.isCompressed()) {
// 裁剪过
path = media.getCutPath();
} else if (media.isCompressed() || (media.isCut() && media.isCompressed())) {
// 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
path = media.getCompressPath();
} else {
// 原图
path = media.getPath();
}
//path转Uri
if (path.startsWith("content://")) {
list.add(Uri.parse(path));
} else {
File file = new File(path);
Uri photoURI = FileProvider.getUriForFile(
getContext(),
getContext().getPackageName() + ".fileProvider",
file
);

list.add(photoURI);
}
}
Uri[] array = list.toArray(new Uri[0]);
filePathCallback.onReceiveValue(array);
}

@Override
public void onCancel() {
filePathCallback.onReceiveValue(null);
}
});
return true;
}
`

**P40效果图片:**

![image](https://user-images.githubusercontent.com/20239404/116517820-10b10f00-a902-11eb-9273-f40ab5bed664.png)
![image](https://user-images.githubusercontent.com/20239404/116519104-a6996980-a903-11eb-973e-885746b0cdf4.png)
![image](https://user-images.githubusercontent.com/20239404/116518372-bc5a5f00-a902-11eb-99d1-b63e419d369f.png)

**Mate20效果图:**

![image](https://user-images.githubusercontent.com/20239404/116517909-33dbbe80-a902-11eb-9597-c612152cfefe.png)
![image](https://user-images.githubusercontent.com/20239404/116517943-3b9b6300-a902-11eb-8679-7dd3d7f25b50.png)

麻烦帮忙看下是什么问题,谢谢了

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the image-selection flow in onShowFileChooser on Huawei Android 10 with EMUI 11, using PictureSelector v2.6.1 and the shown cache callback configuration. Inspect the loading behavior after selecting an image and compare the P40 and Mate20 results. Done means image preview and selection complete without a loading state lasting over 20 seconds or failing to open.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.