JS-HobbySoft / CameraAlign

Other
46 stars 2 forks source link

App crashes at boot, likely permission issue #6

Open Georift opened 1 year ago

Georift commented 1 year ago

Hey thanks for the App. It worked for a little while, but I think after setting a default photo I get a crash at boot.

I'll take a look shortly see if I can spot this issue. Just leaving this here as a reminder to myself. 👍


type: crash osVersion: google/oriole/oriole:13/TQ3A.230705.001/2023070500:user/release-keys package: org.jshobbysoft.cameraalign:4 process: org.jshobbysoft.cameraalign processUptime: 80 + 260 ms  java.lang.RuntimeException: Unable to start activity ComponentInfo{org.jshobbysoft.cameraalign/org.jshobbysoft.cameraalign.MainActivity}: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{1fe52cb 1403:org.jshobbysoft.cameraalign/u0a193} (pid=1403, uid=10193) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3652)   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3789)    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2314)     at android.os.Handler.dispatchMessage(Handler.java:106)     at android.os.Looper.loopOnce(Looper.java:201)  at android.os.Looper.loop(Looper.java:288)  at android.app.ActivityThread.main(ActivityThread.java:7937)    at java.lang.reflect.Method.invoke(Native Method)   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)    at com.android.internal.os.ExecInit.main(ExecInit.java:49)  at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)  at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355) Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{1fe52cb 1403:org.jshobbysoft.cameraalign/u0a193} (pid=1403, uid=10193) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs   at android.os.Parcel.createExceptionOrNull(Parcel.java:3021)    at android.os.Parcel.createException(Parcel.java:3005)  at android.os.Parcel.readException(Parcel.java:2981)    at android.os.Parcel.readException(Parcel.java:2923)    at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5239)   at android.app.ActivityThread.acquireProvider(ActivityThread.java:7072)     at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:3463)    at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2552)   at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2032)  at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1986)  at android.graphics.ImageDecoder$ContentResolverSource.createImageDecoder(ImageDecoder.java:280)    at android.graphics.ImageDecoder.decodeDrawableImpl(ImageDecoder.java:1827)     at android.graphics.ImageDecoder.decodeDrawable(ImageDecoder.java:1819)     at android.widget.ImageView.getDrawableFromUri(ImageView.java:1019)     at android.widget.ImageView.resolveUri(ImageView.java:988)  at android.widget.ImageView.setImageURI(ImageView.java:562)     at androidx.appcompat.widget.e0.setImageURI(SourceFile:1)   at org.jshobbysoft.cameraalign.MainActivity.onCreate(SourceFile:196)    at android.app.Activity.performCreate(Activity.java:8389)   at android.app.Activity.performCreate(Activity.java:8368)   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1422)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3633)   ... 14 more Caused by: android.os.RemoteException: Remote stack trace:  at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:663)  at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:276)   at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:141)   at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:6581)    at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2403) ```
JS-HobbySoft commented 1 year ago

Thanks for leaving that crash report and for starting the issue. I'll use it as a place to keep notes for myself as well.

I've received some crash reports before and it looks like a permission issue, but I haven't been able to reproduce the crash in my Android Studio emulators or the physical devices I have. The crash report mentions that I have to obtain access using ACCESS_OPEN_DOCUMENT. I thought I did that in line 81 in MainActivity.kt, but I must have missed something somewhere.

If you could take a look I'd definitely appreciate it. I'm still clawing my way up the learning curve.

Saimyx commented 1 year ago

Hello, the app crashes at boot on my smartphone too (Android 12). I think it's since the v2.2.

JS-HobbySoft commented 1 year ago

Thanks for the crash report. I'm still trying to reproduce the issue on my devices or emulators. What device do you have?

Georift commented 1 year ago

Very delayed reply, I'm running Graphene OS on a Pixel 6. That's probably the cause if I were to guess. Permissions can sometimes be a little more locked down.

JS-HobbySoft commented 1 year ago

Thanks for the reply, I'd agree with your assessment. I've been meaning to try GrapheneOS, maybe this is a sign I need to install it.

lufte commented 10 months ago

The way I made it crash was:

  1. Load background image
  2. Close app
  3. Delete background image from gallery
  4. Try to open app again

I was not able to open the app again until I reinstalled it, which makes me think the app is trying to load a file that doesn't exist anymore.

JS-HobbySoft commented 10 months ago

@lufte Thanks for that crash report. You were right, the app didn't have any error checking on the background image load process. I released v3.2 to fix the issue.

JS-HobbySoft commented 10 months ago

To continue my notes on the permission-related crashes, I installed GrapheneOS on a Pixel 5 that I had lying around and the app loaded without crashing. I just used the defaults so there may be a setting somewhere that changes the permission handling. I'll still keep tinkering with it. It's a little strange to be disappointed when my app doesn't crash, but at this point I'd be very happy to see the permission crash on my own device or emulator where I could debug it.