Search code examples
codenameone

CN1 app hangs when launching closed app via iOS universal link


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

Solution

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