Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when loading PDF from cloud storage via SAF #412

Open
PatrykMis opened this issue Nov 16, 2024 · 0 comments
Open

Fix crash when loading PDF from cloud storage via SAF #412

PatrykMis opened this issue Nov 16, 2024 · 0 comments
Labels

Comments

@PatrykMis
Copy link
Contributor

Let's say we have PDF on Nextcloud which can be accessed with SAF. File is not downloaded offline before. When trying to open via AOSP file manager or PDFViewer:

type: crash
osVersion: google/shiba/shiba:14/AP2A.240905.003/2024092900:user/release-keys
package: app.grapheneos.pdfviewer:19
process: app.grapheneos.pdfviewer
processUptime: 378 + 205 ms
installer: app.grapheneos.apps

java.lang.RuntimeException: Unable to start activity ComponentInfo{app.grapheneos.pdfviewer/app.grapheneos.pdfviewer.PdfViewer}: android.os.NetworkOnMainThreadException
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4004)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4184)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:114)
	at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:231)
	at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:152)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:93)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2602)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8623)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
	at com.android.internal.os.ExecInit.main(ExecInit.java:50)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:369)
Caused by: android.os.NetworkOnMainThreadException
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3202)
	at android.os.Parcel.createException(Parcel.java:3176)
	at android.os.Parcel.readException(Parcel.java:3152)
	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:202)
	at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:165)
	at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:814)
	at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2068)
	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1883)
	at android.content.ContentResolver.openInputStream(ContentResolver.java:1553)
	at app.grapheneos.pdfviewer.PdfViewer.z(Unknown Source:14)
	at app.grapheneos.pdfviewer.PdfViewer.onCreate(Unknown Source:693)
	at android.app.Activity.performCreate(Activity.java:9013)
	at android.app.Activity.performCreate(Activity.java:8991)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1531)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3986)
	... 15 more

If the only way to access that kind of file is to grant network permission, the user should be notified the file have to be downloaded first (either by making it offline via Nextcloud app or moving it to device's local storage first).

@thestinger thestinger added the bug label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants