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

Catima Import / Export: Move to background thread (ProgressDialog is deprecated, flow is buggy, crashes importing some online files) #513

Open
waffshappen opened this issue Oct 20, 2021 · 3 comments · May be fixed by #1801
Assignees
Labels
common: uncommon Most users are unlikely to come across this or unexpected workflow severity: major Severely degrades major functionality or product features, with no satisfactory workaround type: bug Something isn't working

Comments

@waffshappen
Copy link
Contributor

The ProgressDialog with has been deprecated.

The Recommendation hint seems to be to use a Notification (can also show progress) and move the cancel option there.

That would also mean most imports go through cleanly without being ended by users, probably leaving cleaner Databases.

@TheLastProject
Copy link
Member

I think for the first version using indeterminate progress in the notification is fine :)

@TheLastProject TheLastProject added type: enhancement New feature or request state: help wanted I looked into this issue but couldn't solve it quickly labels Oct 20, 2021
@TheLastProject
Copy link
Member

I've started working on this in #622, but it doesn't quite work as I'd like it yet.

@TheLastProject TheLastProject removed the state: help wanted I looked into this issue but couldn't solve it quickly label Dec 18, 2021
@TheLastProject TheLastProject added common: uncommon Most users are unlikely to come across this or unexpected workflow severity: tolerable Low/no impact on users labels Feb 5, 2022
@TheLastProject TheLastProject changed the title Catima Export: ProgressDialog is deprecated Catima Export: Move to background thread (ProgressDialog is deprecated and flow is buggy) Oct 8, 2022
@TheLastProject TheLastProject changed the title Catima Export: Move to background thread (ProgressDialog is deprecated and flow is buggy) Catima Import / Export: Move to background thread (ProgressDialog is deprecated and flow is buggy) Oct 8, 2022
@TheLastProject
Copy link
Member

TheLastProject commented Jun 29, 2023

The current flow can also crash, for example when importing a large file from NextCloud, because Android punishes doing network on the main thread by throwing a NetworkOnMainThreadException:

FATAL EXCEPTION: main                                                                                                      
Process: me.hackerchick.catima.debug, PID: 31923                                                                          
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=793836462, result=-1, data=Intent { dat=content://org.nextcloud.documents/... fl
g=0x1 }} to activity {me.hackerchick.catima.debug/protect.card_locker.ImportExportActivity}: android.os.NetworkOnMainThreadException
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5335)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:5374)
    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67)
    at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
    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:2303)
    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:7884)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: android.os.NetworkOnMainThreadException
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3021)
    at android.os.Parcel.createException(Parcel.java:2995)
    at android.os.Parcel.readException(Parcel.java:2978)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
    at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153)
    at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:780)
    at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2027)
    at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1842)
    at android.content.ContentResolver.openInputStream(ContentResolver.java:1518)
    at protect.card_locker.ImportExportActivity.openFileForImport(ImportExportActivity.java:165)
    at protect.card_locker.ImportExportActivity.lambda$onCreate$1$protect-card_locker-ImportExportActivity(ImportExportActivity.java:101)
    at protect.card_locker.ImportExportActivity$$ExternalSyntheticLambda7.onActivityResult(Unknown Source:4)
    at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:418)
    at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:375)
    at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:793)
    at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:164)
    at android.app.Activity.dispatchActivityResult(Activity.java:8664)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5328)
    ... 13 more

Note: This only happens with bigger files, my example 544 byte import does not trigger this, but my 1.4MB of real data does. Clearly, Android has set a time limit on doing network on the main thread and the 1.4MB import hits the time limit.

@TheLastProject TheLastProject changed the title Catima Import / Export: Move to background thread (ProgressDialog is deprecated and flow is buggy) Catima Import / Export: Move to background thread (ProgressDialog is deprecated, flow is buggy, crashes importing some online files) Jun 29, 2023
@obfusk obfusk mentioned this issue Jul 17, 2023
9 tasks
@obfusk obfusk mentioned this issue Oct 15, 2023
49 tasks
TheLastProject added a commit that referenced this issue Feb 7, 2024
While #513 needs to be
fixed, this at very least prevents a crash with only mild user
inconvenience in a not commonly used activity
@TheLastProject TheLastProject self-assigned this Mar 26, 2024
@TheLastProject TheLastProject linked a pull request Mar 26, 2024 that will close this issue
8 tasks
@TheLastProject TheLastProject added type: bug Something isn't working severity: major Severely degrades major functionality or product features, with no satisfactory workaround and removed type: enhancement New feature or request severity: tolerable Low/no impact on users labels Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common: uncommon Most users are unlikely to come across this or unexpected workflow severity: major Severely degrades major functionality or product features, with no satisfactory workaround type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants