-
Notifications
You must be signed in to change notification settings - Fork 996
Description
Is there an existing issue for this?
- I have searched the existing issues
Flutter Quill version
Commit 9840745
Steps to reproduce
This issue is on Android only and is platform-specific in the Android JVM.
- Run the app on Android, copy an image from another app while the app is running.
- Paste it into the app, it should succeed without any issues.
- Refrain from copying anything to the clipboard after that.
- Close the app completely and then start it again (using
flutter run), you might get a crash. - If you didn't get any crashes, try to paste the same image from step 1.
The issue can happen on quill_native_bridge and super_clipboard (see super_native_extensions #435 for the related issue) implementation.
On super_clipbaord the Android app can crash, on the quill_native_bridge implementation introduced in #2230. The plugin will simply return null to getClipboardGif() or getClipboardImage and print a message only on debug mode referencing this issue.
The issue is that the app can lose access to the android.net.Uri on the clipboard and a workaround (to actually return the image instead of ignoring it) is to save it to a temporary location or somewhere where the image can be accessed on the app restart or lifecycle changes on the next time calling getClipboardImage.
I had to introduce this workaround instead of fixing it since saving images to the user's device (even if it's specific to the app document directory) is not ideal, the developer or the end user might not want this behavior on their apps/devices.
Expected results
To be able to retrieve the image without this crash/exception.
Once super_native_extensions #435 is confirmed and fixed, this will not be an issue for the SuperClipboardService implementation.
The DefaultClipboardService will return null and print a message on debug-only mode instead of crashing the app due to an unhandled exception from the Android code side (SecurityException or FileNotFoundException from java.io).
Actual results
App crashes on super_clipbaord implementation. For quill_native_bridge caused unhandled exception from the dart side (still not published #2230), updated to simply print a warning and handle it from the dart side and return null, image will not be available and will not have it pasted on the editor.
Additional Context
This is tested using quill_native_bridge.
For super_clipboard video refer to super_native_extensions #435
Screenshots / Video demonstration
For super_clipboard video refer to super_native_extensions #435
Screen.Recording.2024-09-18.at.4.53.08.PM.mov
Logs
Unhandled Exception: PlatformException(COULD_NOT_DECODE_IMAGE, Could not decode bitmap from Uri: Permission Denial: opening provider org.chromium.chrome.browser.util.ChromeFileProvider from ProcessRecord{b3d4d8e 14685:dev.flutterquill.quill_native_bridge_example/u0a191} (pid=14685, uid=10191) that is not exported from UID 10146, java.lang.SecurityException: Permission Denial: opening provider org.chromium.chrome.browser.util.ChromeFileProvider from ProcessRecord{b3d4d8e 14685:dev.flutterquill.quill_native_bridge_example/u0a191} (pid=14685, uid=10191) that is not exported from UID 10146, null)
E/flutter (14685): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
E/flutter (14685): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter (14685): <asynchronous suspension>
E/flutter (14685): #2 MethodChannelQuillNativeBridge.getClipboardImage (package:quill_native_bridge/src/quill_native_bridge_method_channel.dart:87:24)
E/flutter (14685): <asynchronous suspension>
E/flutter (14685): #3 Buttons.build.<anonymous closure> (package:quill_native_bridge_example/main.dart:150:32)
E/flutter (14685): <asynchronous suspension>
E/flutter (14685): java.io.FileNotFoundException: No content provider: content://com.android.chrome.FileProvider/images/screenshot/17266705501256549663602733807552.gif
W/System.err(17433): at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2029)
W/System.err(17433): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1858)
W/System.err(17433): at android.content.ContentResolver.openInputStream(ContentResolver.java:1528)java.lang.SecurityException: Permission Denial: opening provider org.chromium.chrome.browser.util.ChromeFileProvider from ProcessRecord{d1d20d7 17742:dev.flutterquill.quill_native_bridge_example/u0a191} (pid=17742, uid=10191) that is not exported from UID 10146
W/System.err(17742): at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
W/System.err(17742): at android.os.Parcel.createException(Parcel.java:3041)
W/System.err(17742): at android.os.Parcel.readException(Parcel.java:3024)
W/System.err(17742): at android.os.Parcel.readException(Parcel.java:2966)
W/System.err(17742): at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5906)
W/System.err(17742): at android.app.ActivityThread.acquireProvider(ActivityThread.java:7310)
W/System.err(17742): at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:3668)
W/System.err(17742): at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2542)
W/System.err(17742): at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2027)
W/System.err(17742): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1858)
W/System.err(17742): at android.content.ContentResolver.openInputStream(ContentResolver.java:1528)
W/System.err(17742): at dev.flutterquill.quill_native_bridge.clipboard.ClipboardImageHandler.canRead(ClipboardImageHandler.kt:86)
W/System.err(17742): at dev.flutterquill.quill_native_bridge.clipboard.ClipboardImageHandler.getClipboardImage(ClipboardImageHandler.kt:114)
W/System.err(17742): at dev.flutterquill.quill_native_bridge.QuillNativeBridgePlugin.onMethodCall(QuillNativeBridgePlugin.kt:169)
W/System.err(17742): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
W/System.err(17742): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
W/System.err(17742): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
W/System.err(17742): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
W/System.err(17742): at android.os.Handler.handleCallback(Handler.java:958)
W/System.err(17742): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(17742): at android.os.Looper.loopOnce(Looper.java:205)
W/System.err(17742): at android.os.Looper.loop(Looper.java:294)
W/System.err(17742): at android.app.ActivityThread.main(ActivityThread.java:8177)
W/System.err(17742): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(17742): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
W/System.err(17742): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
W/System.err(17742): Caused by: android.os.RemoteException: Remote stack trace:
W/System.err(17742): at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:691)
W/System.err(17742): at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:287)
W/System.err(17742): at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:144)
W/System.err(17742): at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:6713)
W/System.err(17742): at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2761)