CaiJingLong / flutter_photo

Pick image/video from album by flutter. Support ios and android. UI by flutter, no native.
Apache License 2.0
301 stars 132 forks source link

[Need Help] 安卓10选择视频打开相册崩溃 #109

Closed atheist1 closed 4 years ago

atheist1 commented 4 years ago

Description

Describe your problem as clearly as possible. 选择图片没有问题,选择视频在加载界面直接崩溃,开发模式与生产模式均崩溃,没有任何报错信息。

More info

手机版本如下图

image Additional information such as prototypes or screenshots can help developers understand what you mean.

Gist code

List<AssetEntity> sourceList = await PhotoPicker.pickAsset(
      context: context,
      // BuildContext requied
      checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
        activeColor: Colors.white,
        unselectedColor: Colors.white,
        checkColor: Colors.green,
      ),
      /// The following are optional parameters.
      themeColor: Color(McColors.backgroundDark),
      // the title color and bottom color
      padding: 1.0,
      // item padding
      dividerColor: Colors.grey,
      // divider color
      disableColor: Colors.grey.shade300,
      // the check box disable color
      itemRadio: 0.88,
      // the content item radio
      maxSelected: pickNum,
      // max picker image count
      provider: I18nProvider.chinese,
      // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
      rowCount: 5,
      // item row count
      textColor: Colors.white,
      // text color
      thumbSize: 64,
      // preview thumb size , default is 64
      sortDelegate: SortDelegate
          .common, // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate
      // badgeDelegate: const DefaultBadgeDelegate(),
      pickType: type,
    );

Plugin version

0.4.7 0.4.8均出现同样问题

CaiJingLong commented 4 years ago
  1. Please open android folder(no flutter) in android studio.
  2. And run your project.
  3. See the logcat label.

If crash, post the log into there.

atheist1 commented 4 years ago
  1. Please open android folder(no flutter) in android studio.
  2. And run your project.
  3. See the logcat label.

If crash, post the log into there. 这里是日志

java.io.FileNotFoundException: Failed to create thumbnail
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:149)
at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:705)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1698)
at android.content.ContentResolver.openTypedAssetFile(ContentResolver.java:1603)
at android.content.ContentResolver.lambda$loadThumbnail$0(ContentResolver.java:3628)
at android.content.-$$Lambda$ContentResolver$7ILY1SWNxC2xhk-fQUG6tAXW9Ik.call(Unknown Source:10)
at android.graphics.ImageDecoder$CallableSource.createImageDecoder(ImageDecoder.java:550)
at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1847)
at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1840)
at android.content.ContentResolver.loadThumbnail(ContentResolver.java:3627)
at android.content.ContentResolver.loadThumbnail(ContentResolver.java:3611)
at top.kikt.imagescanner.core.utils.AndroidQDBUtils.getThumb(AndroidQDBUtils.kt:300)
at top.kikt.imagescanner.core.PhotoManager.getThumb(PhotoManager.kt:85)
at top.kikt.imagescanner.core.PhotoManagerPlugin.onHandlePermissionResult(PhotoManagerPlugin.kt:198)
at top.kikt.imagescanner.core.PhotoManagerPlugin.access$onHandlePermissionResult(PhotoManagerPlugin.kt:23)
at top.kikt.imagescanner.core.PhotoManagerPlugin$onMethodCall$$inlined$apply$lambda$1.onGranted(PhotoManagerPlugin.kt:134)
at top.kikt.imagescanner.old.permission.PermissionsUtils.getPermissionsWithTips(PermissionsUtils.java:129)
at top.kikt.imagescanner.old.permission.PermissionsUtils.getPermissions(PermissionsUtils.java:103)
at top.kikt.imagescanner.core.PhotoManagerPlugin.onMethodCall(PhotoManagerPlugin.kt:145)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:363)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:8169)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

java.lang.IllegalArgumentException: Unsupported value: java.io.FileNotFoundException: Failed to create thumbnail
at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:294)
at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:239)
at top.kikt.imagescanner.util.ResultHandler$replyError$1.run(ResultHandler.kt:26)
at android.os.Handler.handleCallback(Handler.java:888)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:8169)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)```
CaiJingLong commented 4 years ago

简单解释下: 资源的文件实体被别的程序删除, 但该程序未更新MediaStore

我可以在下版本中屏蔽该crash,并将异常捕获为不crash的方式, 但相对应的, 会有一个无法使用的占位资源存在

不能屏蔽资源的获取, 因为遍历所有文件是否存在效率太低. 正确的方式应该是由删除图片的app来删除MediaStore中的数据行.

另外, 这种系统资源在重启手机时会重新扫描媒体库, 这时候不存在的图片的MediaStore数据库记录会被删除


English version from google trans:

The file entity of the resource was deleted by another program, but the program did not update the MediaStore

I can shield the crash in the next version and catch the exception as a way to not crash, but correspondingly, there will be an unusable placeholder resource.

Can't block the acquisition of resources, because it is too inefficient to traverse all files. The correct way is to delete the data rows in the MediaStore by the app that deletes pictures.

In addition, this system resource will rescan the media library when the phone is restarted, and the MediaStore database records of pictures that do not exist at this time will be deleted.

atheist1 commented 4 years ago

资源

多谢你的回复,但是我并不知道是什么程序导致的MediaStore没被更新的,如果仅仅是出现占位资源的话是能接受的。还有你说的在重启手机会重新扫描会重新更新数据库是这个版本就有的吗?我尝试过重启手机是无效的

CaiJingLong commented 4 years ago

@atheist1 正常来说, 重启手机会自动扫描, 当然不排除某些rom定制后没做这事, 因为这事情是耗时操作, 也许为了"加快手机重启速度,优化用户体验"把这步去掉了

atheist1 commented 4 years ago

重启手 如果真是这个问题的话那就期待你下次更新了,感谢

pmrajani commented 4 years ago

E/PhotoManagerPlugin(12590): java.io.FileNotFoundException: Failed to create thumbnail E/PhotoManagerPlugin(12590): at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:149) E/PhotoManagerPlugin(12590): at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:705) E/PhotoManagerPlugin(12590): at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1698) E/PhotoManagerPlugin(12590): at android.content.ContentResolver.openTypedAssetFile(ContentResolver.java:1603) E/PhotoManagerPlugin(12590): at android.content.ContentResolver.lambda$loadThumbnail$0(ContentResolver.java:3628) E/PhotoManagerPlugin(12590): at android.content.-$$Lambda$ContentResolver$7ILY1SWNxC2xhk-fQUG6tAXW9Ik.call(Unknown Source:10) E/PhotoManagerPlugin(12590): at android.graphics.ImageDecoder$CallableSource.createImageDecoder(ImageDecoder.java:550) E/PhotoManagerPlugin(12590): at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1847) E/PhotoManagerPlugin(12590): at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1840) E/PhotoManagerPlugin(12590): at android.content.ContentResolver.loadThumbnail(ContentResolver.java:3627) E/PhotoManagerPlugin(12590): at android.content.ContentResolver.loadThumbnail(ContentResolver.java:3611) E/PhotoManagerPlugin(12590): at top.kikt.imagescanner.core.utils.AndroidQDBUtils.getThumb(AndroidQDBUtils.kt:300) E/PhotoManagerPlugin(12590): at top.kikt.imagescanner.core.PhotoManager.getThumb(PhotoManager.kt:85) E/PhotoManagerPlugin(12590): at top.kikt.imagescanner.core.PhotoManagerPlugin.onHandlePermissionResult(PhotoManagerPlugin.kt:198) E/PhotoManagerPlugin(12590): at top.kikt.imagescanner.core.PhotoManagerPlugin.access$onHandlePermissionResult(PhotoManagerPlugin.kt:23) E/PhotoManagerPlugin(12590): at top.kikt.imagescanner.core.PhotoManagerPlugin$onMethodCall$$inlined$apply$lambda$1.onGranted(PhotoManagerPlugin.kt:134) E/PhotoManagerPlugin(12590): at top.kikt.imagescanner.old.permission.PermissionsUtils.getPermissionsWithTips(PermissionsUtils.java:129) E/PhotoManagerPlugin(12590): at top.kikt.imagescanner.old.permission.PermissionsUtils.getPermissions(PermissionsUtils.java:103) E/PhotoManagerPlugin(12590): at top.kikt.imagescanner.core.PhotoManagerPlugin.onMethodCall(PhotoManagerPlugin.kt:145) E/PhotoManagerPlugin(12590): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231) E/PhotoManagerPlugin(12590): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93) E/PhotoManagerPlugin(12590): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642) E/PhotoManagerPlugin(12590): at android.os.MessageQueue.nativePollOnce(Native Method) E/PhotoManagerPlugin(12590): at android.os.MessageQueue.next(MessageQueue.java:363) E/PhotoManagerPlugin(12590): at android.os.Looper.loop(Looper.java:173) E/PhotoManagerPlugin(12590): at android.app.ActivityThread.main(ActivityThread.java:8178) E/PhotoManagerPlugin(12590): at java.lang.reflect.Method.invoke(Native Method) E/PhotoManagerPlugin(12590): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) E/PhotoManagerPlugin(12590): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101) I/BlockMonitor(12590): dispatchingThrewException In MainThread D/AndroidRuntime(12590): Shutting down VM I/QarthLog(12590): [PatchStore] createDisableExceptionQarthFile

pmrajani commented 4 years ago

E/AndroidRuntime(12590): java.lang.IllegalArgumentException: Unsupported value: java.io.FileNotFoundException: Failed to create thumbnail E/AndroidRuntime(12590): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:294) E/AndroidRuntime(12590): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70) E/AndroidRuntime(12590): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:239) E/AndroidRuntime(12590): at top.kikt.imagescanner.util.ResultHandler$replyError$1.run(ResultHandler.kt:26) E/AndroidRuntime(12590): at android.os.Handler.handleCallback(Handler.java:888) E/AndroidRuntime(12590): at android.os.Handler.dispatchMessage(Handler.java:100) E/AndroidRuntime(12590): at android.os.Looper.loop(Looper.java:213) E/AndroidRuntime(12590): at android.app.ActivityThread.main(ActivityThread.java:8178) E/AndroidRuntime(12590): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(12590): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) E/AndroidRuntime(12590): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

pmrajani commented 4 years ago

image

I am using latest photo: ^0.4.8 version. Can we get fix this? i thought it's only happens in Huawei devices. other device no issue. @atheist1 @CaiJingLong

atheist1 commented 4 years ago

@pmrajani i just modified the code that in ios/.symlinks/plugins/photo_manager/android/src/main/kotlin/top/kikt/imagescanner/core/utils/AndroidQDBUtils.kt

override fun getThumb(context: Context, id: String, width: Int, height: Int, type: Int?): Bitmap? {
    if (type == null) {
      return null
    }
    val uri = getUri(id, type)
    try {
      return context.contentResolver.loadThumbnail(uri, Size(width, height), null)
    } catch(e:Exception) {
      return null
    } 

  }
CaiJingLong commented 4 years ago

The problem by resolve in https://github.com/CaiJingLong/flutter_photo_manager/pull/215. When the manager is ready, I will update the photo.

pmrajani commented 4 years ago

@atheist1 @CaiJingLong Any news when new version will release?

CaiJingLong commented 4 years ago

Now, you can use 0.5.0-dev.1.

There are still some changes to photo_manager, waiting for the release of photo_manager, I will update the photo to the stable version.

rignaneseleo commented 4 years ago

The issue is not fixed