stefan-niedermann / nextcloud-deck

📋 Android client for nextcloud deck app
https://play.google.com/store/apps/details?id=it.niedermann.nextcloud.deck.play
GNU General Public License v3.0
490 stars 53 forks source link

crash when adding list widget to homescreen #806

Closed fm-sys closed 3 years ago

fm-sys commented 3 years ago

Please use GitHub reactions 👍 to show that you are affected by the same issue. Please don't comment if you have no relevant information to add!

Describe the bug

crash when adding list widget to homescreen

To reproduce Issue is reproducible with an account from try.nextcloud.com:

Steps to reproduce the behavior:

  1. Move widget to homescreen
  2. Select list and confirm
  3. Nothing happens. Launcher reloads all app icons

Expected behavior

Widget gets added

Versions

Smartphone (please complete the following information):

Stacktrace

FATAL EXCEPTION: main
Process: com.huawei.android.launcher, PID: 2142
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=5, result=-1, data=Intent { act=android.appwidget.action.APPWIDGET_UPDATE cmp=it.niedermann.nextcloud.deck/.ui.widget.stack.StackWidget (has extras) }} to activity {com.huawei.android.launcher/com.huawei.android.launcher.unihome.UniHomeLauncher}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.toUri(int)' on a null object reference
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5471)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:5512)
    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2386)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:213)
    at android.app.ActivityThread.main(ActivityThread.java:8178)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.toUri(int)' on a null object reference
    at com.huawei.android.launcher.LauncherAppWidgetInfo.onAddToDatabase(LauncherAppWidgetInfo.java:222)
    at com.huawei.android.launcher.LauncherModel.addItemToDatabase(LauncherModel.java:1397)
    at com.huawei.android.launcher.Launcher.addWidgetToScreen(Launcher.java:2688)
    at com.huawei.android.launcher.Launcher.completeAddAppWidget(Launcher.java:2742)
    at com.huawei.android.launcher.Launcher.completeAdd(Launcher.java:1397)
    at com.huawei.android.launcher.Launcher.onActivityResult(Launcher.java:1461)
    at android.app.Activity.dispatchActivityResult(Activity.java:8413)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5464)
    ... 11 more
stefan-niedermann commented 3 years ago

Thanks for the report. Are you able to reproduce the issue or was that a one-shot?

fm-sys commented 3 years ago

Always reproducible for me but probably device specific. I even tried to reinstall the Deck but the bug still exists...

stefan-niedermann commented 3 years ago

I wonder whether this might be related to the issues on the Xiaomi launcher :thinking:

Well, the list widget was written with poor knowledge. Do you have the same issues with the "Upcoming cards" widget? Since you are on F-Droid, you should already be able to use this in the most recent version. Because if you are able to add the "Upcoming cards" widget to your launcher without any troubles, this issue will likely get solved as soon as we migrated the list widget to the new Filter Widget infrastructure (= complete rewrite).

fm-sys commented 3 years ago

"Upcoming cards" is working for me (no crash), but it shows all cards which haven't any due-date and these with a due-date aren't listed at all 😅

And it currently looks not really well-designed, but this is a totally different topic ;-)

stefan-niedermann commented 3 years ago

"Upcoming cards" is working for me (no crash), but it shows all cards which haven't any due-date and these with a due-date aren't listed at all 😅

Well, that's another topic, indeed - it's an early draft which also has not been released on Play Store production channel because of a few known issues.

The important part here is, that it doesn't crash while adding it, so i really believe that #767 will solve this becauss of the different technologie¹ we used - it also should solve some refresh-issues for users who are able to add it without crash. Let's track it down in #767 therefore (you can subscribe to this issue) and just reopen this once #767 has been closed and you are still not able to add the widget. 😉

¹ Tech details: The list widget uses LiveData everywhere, what is dumb because we don't actually have a Lifecycle and thus no LifecycleOwner. For this reason we use .observeForever which is dangerous and might also cause leaks. The Upcoming cards widget on the other side uses traditional refresh mechanisms which basically are less error prone and work better.

And it currently looks not really well-designed

Looking forward to your Pull Request.

fm-sys commented 3 years ago

And it currently looks not really well-designed

Looking forward to your Pull Request.

A never have worked with widgets either, but what about displaying labels etc in there? So basically the same UI as inside the app...?

stefan-niedermann commented 3 years ago

We will continue to work on the "Upcoming cards" widget, no worries :slightly_smiling_face: It's a proof of concept to see whether it works or not (because Android is a bitch and we don't know that much about Android stuff either) - let's first get it work, publish for all users and then enhance it :) in little steps.

We will discuss with the UX engineers of Nextcloud about what we will actually display in the future :)