fossasia / open-event-organizer-android

Open Event Mobile App for Organizers and Entry Managers https://play.google.com/store/apps/details?id=com.eventyay.organizer
Apache License 2.0
1.79k stars 490 forks source link

Bug: App crashes after selecting a local image for new event #2001

Closed krharsh17 closed 4 years ago

krharsh17 commented 4 years ago

Describe the bug The app crashes after selecting a graphic from the phone storage.

To Reproduce

  1. Go to New Event
  2. Fill event details and reach Step 3
  3. Click on the camera icon to select a graphic from phone.
  4. As soon as you select an image, the app crashes

Expected behavior The image should be selected and loaded in the specified space.

Logs PID: 23932 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:58274 flg=0x1 }} to activity {com.eventyay.organizer/com.eventyay.organizer.core.event.create.CreateEventActivity}: java.lang.RuntimeException: StrictMode ThreadPolicy violation at android.app.ActivityThread.deliverResults(ActivityThread.java:4617) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4659) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7078) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974) Caused by: java.lang.RuntimeException: StrictMode ThreadPolicy violation at android.os.StrictMode$AndroidBlockGuardPolicy.onThreadPolicyViolation(StrictMode.java:1705) at android.os.StrictMode$AndroidBlockGuardPolicy.handleViolationWithTimingAttempt(StrictMode.java:1562) at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:2141) at android.os.Parcel.readExceptionCode(Parcel.java:1912) at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:140) at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:698) at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1465) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1302) at android.content.ContentResolver.openInputStream(ContentResolver.java:1022) at com.eventyay.organizer.core.event.create.EventDetailsStepThree.onActivityResult(EventDetailsStepThree.java:108) at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:170) at android.app.Activity.dispatchActivityResult(Activity.java:7762) at android.app.ActivityThread.deliverResults(ActivityThread.java:4610) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4659)  at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:214)  at android.app.ActivityThread.main(ActivityThread.java:7078)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)  Caused by: android.os.strictmode.DiskWriteViolation at android.os.StrictMode$AndroidBlockGuardPolicy.onWriteToDisk(StrictMode.java:1460) at android.database.sqlite.SQLiteConnection.applyBlockGuardPolicy(SQLiteConnection.java:1383) at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:943) at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754) at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64) at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:2126) at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:2072) at com.android.providers.media.MediaProvider.queryForDataFile(MediaProvider.java:6259) at com.android.providers.media.MediaProvider.openFileAndEnforcePathPermissionsHelper(MediaProvider.java:6281) at com.android.providers.media.MediaProvider.openFile(MediaProvider.java:6115) at android.content.ContentProvider.openAssetFile(ContentProvider.java:1566) at android.content.ContentProvider.openTypedAssetFile(ContentProvider.java:1746) at android.content.ContentProvider.openTypedAssetFile(ContentProvider.java:1812) at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:425) at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1465) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1302) 2019-12-13 20:29:29.186 23932-23932/com.eventyay.organizer E/AndroidRuntime: at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1155) at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1109) at com.android.providers.media.MediaDocumentsProvider.openDocument(MediaDocumentsProvider.java:754) at android.provider.DocumentsProvider.openAssetFile(DocumentsProvider.java:1200) at android.provider.DocumentsProvider.openTypedAssetFileImpl(DocumentsProvider.java:1310) at android.provider.DocumentsProvider.openTypedAssetFile(DocumentsProvider.java:1242) at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:425) at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:302) at android.os.Binder.execTransact(Binder.java:739)

Screenshots

Smartphone Info: |Device |Samsung Galaxy J8| |Android Version|Pie 9.0|

Additional context The problem appears to be due to the StrictMode Policies

Would you like to work on the issue?

theindianappguy commented 4 years ago

I have faced same issue, additionally when going to the account from the drawer then clicking on the profile picture shows gallery to select an image when images selected, app crashes later I realize it should ask for permission when the app first launches

Later while testing on Emulator I got this notification Leak Analysis... something and after some time showing Leak Analysis Done when clicked showing the permission dialog Emulator Used: Pixel 2 API 28

krharsh17 commented 4 years ago

@theindianappguy I went through what you observed and it seems that StrictMode again is the culprit here. Even after granting the permissions, the app crashed after selecting an image. These are the logs that I got:

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65539, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:58921 flg=0x1 }} to activity {com.eventyay.organizer/com.eventyay.organizer.core.organizer.detail.OrganizerDetailActivity}: java.lang.RuntimeException: StrictMode ThreadPolicy violation
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4617)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4659)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7078)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)
     Caused by: java.lang.RuntimeException: StrictMode ThreadPolicy violation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onThreadPolicyViolation(StrictMode.java:1705)
        at android.os.StrictMode$AndroidBlockGuardPolicy.handleViolationWithTimingAttempt(StrictMode.java:1562)
        at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:2141)
        at android.os.Parcel.readExceptionCode(Parcel.java:1912)
        at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:140)
        at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:698)
        at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1465)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1302)
        at android.content.ContentResolver.openInputStream(ContentResolver.java:1022)
        at com.eventyay.organizer.core.organizer.detail.OrganizerDetailFragment.onActivityResult(OrganizerDetailFragment.java:245)
        at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:170)
        at android.app.Activity.dispatchActivityResult(Activity.java:7762)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4610)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4659) 
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7078) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974) 
     Caused by: android.os.strictmode.DiskWriteViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onWriteToDisk(StrictMode.java:1460)
        at android.database.sqlite.SQLiteConnection.applyBlockGuardPolicy(SQLiteConnection.java:1383)
        at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:846)
        at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:490)
        .
        .

But I do not understand why StrictMode is working even when developer mode is turned off.

iamareebjamal commented 4 years ago

Because it's debug build. Let's turn strict mode to log only because it is clearly broken