woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
278 stars 134 forks source link

RuntimeException: An error occurred while executing doInBackground() #2615

Closed sentry-io[bot] closed 10 months ago

sentry-io[bot] commented 4 years ago

Sentry Issue: WOOCOMMERCE-ANDROID-22

RemoteException: Remote stack trace:
    at com.android.server.am.ActivityManagerService.getContentProviderImpl(ActivityManagerService.java:14168)
    at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:14759)
    at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:357)
    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3860)
    at com.android.server.am.OppoActivityManagerService.onTransact(OppoActivityManagerService.java:853)

SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{ae2a343 28725:com.woocommerce.android/u0a314} (pid=28725, uid=10314) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
    at com.woocommerce.android.media.ProductImagesUtils.fetchMedia(ProductImagesUtils.kt:107)
    at com.woocommerce.android.media.ProductImagesUtils.mediaModelFromLocalUri(ProductImagesUtils.kt:36)
    at com.woocommerce.android.media.ProductImagesService.onHandleWork(ProductImagesService.kt:148)
...
(16 additional frame(s) were not displayed)

RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:354)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
...
(2 additional frame(s) were not displayed)

An error occurred while executing doInBackground()

As of July 13: Events: 144 Users affected: 26

sentry-io[bot] commented 4 years ago

Sentry issue: WOOCOMMERCE-ANDROID-22

sentry-io[bot] commented 4 years ago

Sentry issue: WOOCOMMERCE-ANDROID-22

sentry-io[bot] commented 4 years ago

Sentry issue: WOOCOMMERCE-ANDROID-TC

astralbodies commented 4 years ago

@nbradbury Does this look like a permissions issue on the device causing a crash? Is it something we should worry about? I don't see any crashes coming from 4.8 but I'm not sure if that means it was fixed or not.

nbradbury commented 4 years ago

@astralbodies That does look like a permission issue. In the trace I see this:

SecurityException
Permission Denial: reading com.android.providers.media.MediaDocumentsProvider uri 
content://com.android.providers.media.documents/document/image%3A41586 from pid=31494, uid=10157 
requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
astralbodies commented 4 years ago

@nbradbury Can permissions be revoked later by the user or would that cause the app to not launch until the proper required permissions are allowed?

nbradbury commented 4 years ago

Can permissions be revoked later by the user or would that cause the app to not launch until the proper required permissions are allowed?

On older devices, the original permission dialog is shown again. On newer devices we detect whether the user has revoked a permission and ask whether they want to edit their permissions.

Screenshot_1599073941

nbradbury commented 4 years ago

Here's a link to the Google source code that displays that error. Note that the MANAGE_DOCUMENTS permission is only available to system-level apps, so that's nothing we need to do.

nbradbury commented 4 years ago

So, I think that source code is telling us that the media picker does have MANAGE_DOCUMENTS permission, which means it's the system media picker. However, our app doesn't have permission to access that specific media URI, which results in the crash. The error message is telling us we should use ACTION_OPEN_DOCUMENT to access the image (right now we use ACTION_GET_CONTENT).

nbradbury commented 4 years ago

Also, the crash occurs in MediaUtils, which is part of the utility library we share with WPAndroid. There is a related crash happening in WPAndroid, and here's the Sentry crash report.

nbradbury commented 4 years ago

Update: This page suggests using CATEGORY_OPENABLE to restrict images to only those that can be opened by a content resolver. Looking at the WPAndroid crash, the problem happens in this line where we use a content resolver to read the image.

This may be a possible fix.

AmandaRiu commented 3 years ago

Still happening as of 5.2 so reopening.

nbradbury commented 3 years ago

I tried once again to do as the error message said and switch to ACTION_OPEN_DOCUMENT, but that doesn't enable the user to choose from Google Photos, which is a pretty important feature.

pmusolino commented 10 months ago

Issue archived since it's not happening in the latest versions of the app.

pachlava commented 10 months ago

Adding MTTR-exclusion label to avoid this issue getting into MTTR metric for October.2023. The issue was closed as not reproducible, so it should not be included in the metric.