Question on iOS complex threading

23 views
Skip to first unread message

Marisole Aromatherapy

unread,
Jan 18, 2021, 6:51:37 PM1/18/21
to codenameone...@googlegroups.com
I come here seeking help after having nearly given up on a threading problem I face on iOS. Everything works well on Android, but on iOS, very randomly, the UI freezes and becomes unresponsive

This happens while running some new code I made that uses intricate threading mechanisms

At a high level representation, the code goes like this:

EasyThread.run -> //queued execution
    FetchDataAsync -> // get stuff from endpoint
        New Thread -> // do stuff away from edt
            LockObject.notify() // signal easyThread can continue
    LockObject.wait()//pause queue until async processing is done


I have tripple checked that all UI calls made inside these threads are made with callSerially

The problem is so random I can't attribute it to anything in particular, just know that if I comment this code it goes away

No worries if nothing comes to mind, but if this is something anyone has seen before please let me know. Perhaps using wait/notify inside an EasyThread isn't advisable on iOS?

Thanks

Javier

Marisole Aromatherapy

unread,
Jan 18, 2021, 7:10:08 PM1/18/21
to codenameone...@googlegroups.com
Just forgot to add to my previous email that I also tried using synchronize together with wait/notify instead of an EasyThread, but saw the same issue

Thanks

Javier

Shai Almog

unread,
Jan 18, 2021, 9:51:52 PM1/18/21
to CodenameOne Discussions
iOS is generally more sensitive to threading issues so this would make sense. But it's hard to help at this abstraction level. The only option is debugging this in xcode if you can't think of anything else.

Marisole Aromatherapy

unread,
Jan 19, 2021, 3:53:40 AM1/19/21
to codenameone...@googlegroups.com
Interesting, thanks for this

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/e1e2164b-61a6-468f-881c-abbdaa0ca191n%40googlegroups.com.

Marisole Aromatherapy

unread,
Jan 19, 2021, 6:00:47 AM1/19/21
to codenameone...@googlegroups.com
Debugging on xCode shows that calling wait() on a lock throws the error "Thread 22: EXC_BAD_ACCESS (code=1, address=0x78"

This is in line nativeMethods.m:1209 (JAVA_VOID java_lang_Object_wait__long_int...)

I will continue my investigation, but so far this has shed some light on the causes of this

Marisole Aromatherapy

unread,
Jan 19, 2021, 6:11:24 AM1/19/21
to codenameone...@googlegroups.com
Actually, don't worry about this one, I think I know where the problem is coming from (can't say for sure until I build and re-sign, but that will take 30 mins so just please don't spend any time on this)

Thanks

Marisole Aromatherapy

unread,
Jan 19, 2021, 8:34:02 AM1/19/21
to codenameone...@googlegroups.com
Got to the bottom of this. I will reply to this thread in case anyone ever encounters this. The issue was that I wasn't surrounding the wait() call with synchronize. Rookie mistake that only shows up on iOS
Reply all
Reply to author
Forward
0 new messages