1

For our CN1 app on iOS, tapping a universal link works when the app is already opened and in the background but only if it was already opened. When the app is closed before tapping the link, the app hangs on a white screen. The problem seems to be related to the extra stop() cycle referenced on GitHub here. The sequence we are seeing is

init()
stop()
start()    <-- here AppArg == the correct URL but then we get an NPE

The stop() is called about 0.04 seconds after init() is called. The init() normally takes 4+ seconds so it's incomplete when the app gets to start(). When start() tries to work on items not set up yet we get a NPE. Had no luck with the solutions mentioned here. Any suggestions on a fix? Thx!

Stack Trace

default 12:39:50.468359-0600    MyApp   java.lang.NullPointerException
at com_acsdelivers_myapp_MyApp.start:1667
at com_acsdelivers_myapp_MyAppStub.run:29
at com_codename1_ui_Display.executeSerialCall:1395
at com_codename1_ui_Display.processSerialCalls:1379
at com_codename1_ui_Display.edtLoopImpl:1321
at com_codename1_ui_Display.invokeAndBlock:1503
at com_codename1_ui_Display.invokeAndBlock:1542
at com_codename1_impl_ios_IOSImplementation.getAppArg:6194  <---
at com_codename1_ui_Display.getProperty:3440
at com_acsdelivers_myapp_MyApp.init:1232
at com_acsdelivers_myapp_MyAppStub.run:26
at com_codename1_ui_Display.executeSerialCall:1395
at com_codename1_ui_Display.processSerialCalls:1379
at com_codename1_ui_Display.mainEDTLoop:1166
at com_codename1_ui_RunnableWrapper.run:120
at com_codename1_impl_CodenameOneThread.run:176
at java_lang_Thread.runImpl:0
  • I assume you have a log of this. In it you should be able to see the thread that made the call. All three should be invoked on the EDT so `stop()` can't run before `init()` if one of them runs on a non-EDT thread can you get a `printStackTrace()` or similar output? – Shai Almog Jul 15 '23 at 03:29
  • 1
    Thx @Shai for the suggestion. I've added the stack trace for the NPE. It shows the root cause of the crash was the following line which I had added to init() String arg = Display.getInstance().getProperty("AppArg", "tbd"); I had that line in init() and start() just to understand the functionality. Commenting out that line in init() solved the problem. I'll submit the following as the accepted answer tomorrow - avoid getting AppArg during init(). – Mike Clonts Jul 16 '23 at 02:18

1 Answers1

1

Avoid Display.getInstance().getProperty("AppArg", "tbd"); inside the init() method (ref. stack trace and comments).