openlauncher icon indicating copy to clipboard operation
openlauncher copied to clipboard

Crash reports when adding PWAs

Open chrysn opened this issue 1 year ago • 3 comments

General Information

  • OpenLauncher Version: Current nightly (0f7fc2272e1e939dfe263dd8eb99ef3007bac9d6)
  • Android Version: 7.1.2
  • Custom ROM: Lineage
  • Install Source: APK copied out of build artifact

Description

Adding a PWA launcher from Chromium sometimes produces a crash screen:

Log

A crash report was shown:

Build version: 0.7.4 Build date: 1980-01-01 00:00:00 Current date: 2022-09-01 08:33:01 Device: Sony E5823

Stack trace:
java.lang.RuntimeException: Unable to start receiver com.benny.openlauncher.receivers.ShortcutReceiver: java.lang.RuntimeException: Setup has not been initialised! at android.app.ActivityThread.handleReceiver(ActivityThread.java:3072) at android.app.ActivityThread.-wrap18(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6186) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: java.lang.RuntimeException: Setup has not been initialised! at com.benny.openlauncher.manager.Setup.get(Setup.java:25) at com.benny.openlauncher.manager.Setup.appLoader(Setup.java:47) at com.benny.openlauncher.receivers.ShortcutReceiver.onReceive(ShortcutReceiver.java:54) at android.app.ActivityThread.handleReceiver(ActivityThread.java:3065) ... 8 more

Further references

PWA shortcuts were introduced in #637 by @Apollo3zehn -- if you read this and it does ring a bell, hints would be appreciated.

Next steps

I'll yet have to see whether I can make anything of this or fix it myself.

chrysn avatar Sep 01 '22 06:09 chrysn

According to your posted stack trace, the static Setup.java was not initialized: https://github.com/OpenLauncherTeam/openlauncher/blob/a80293e38e7e08525c002a801c25dd643b75f853/app/src/main/java/com/benny/openlauncher/manager/Setup.java#L23-L28

Searching the code shows that only in the HomeActivity, the setup is being initialized: https://github.com/OpenLauncherTeam/openlauncher/blob/22e681e5dada9cb9e7c4fece4428e65040ecfa89/app/src/main/java/com/benny/openlauncher/activity/HomeActivity.java#L186-L188

I do not know why this activity is not executed (and thus the Setup is not being initialized) but maybe it is sufficient to initialize it right before https://github.com/OpenLauncherTeam/openlauncher/blob/a80293e38e7e08525c002a801c25dd643b75f853/app/src/main/java/com/benny/openlauncher/receivers/ShortcutReceiver.java#L54

Unfortunately I am no Java and no App developer, I have not the required understanding to say for sure what the solution is.

Apollo3zehn avatar Sep 01 '22 07:09 Apollo3zehn

Thanks for your input. Based on this, I'd guess that this could all be happening when the launcher app has been unloaded by the OS for being inactive; this would often not show in testing as there one'd be hopping back and forth between the launcher and the PWA installer, and in my tests I've been using Chromium for some time before I pushed the 'install' button.

chrysn avatar Sep 01 '22 07:09 chrysn

Only before Android Oreo. Since Oreo ShortcutReceiver was deprecated in favor of ShortcutManager.pinRequestShortcut(). I made a patch (https://github.com/Ptitg/openlauncher/tree/fix/adding_pwa_crash), but I don't have the right version of android to test. If someone can test. If it's OK, I'll make a pull request.

Ptitg avatar Sep 07 '22 09:09 Ptitg