Open javieranton-zz opened 4 years ago
While this might be a problem I would strongly recommend you don't do that. Showing a dialog on top of a dialog can lead to a problem where disposing the dialog leads back to the previous dialog and this might actually cause a cycle of dialogs disposing and going "back" to each other.
No worries I will work around it
Thx
Could you be a bit more specific, I'd really appreciate it if you could
Does this apply to all types of dialogs? I mean, for example, is it ok to show a Dialog on top of an AnimatedDialog, but not ok to show an infinite blocking over an AnimatedDialog?
Or is there some combination that's safe?
Yes, anything that derives from from dialog will be problematic.
The crux of the issue is the concept of dispose()
it works by going back to the parent Form
. The thing is that Dialog
derives from Form
which is pretty elegant but also problematic. So when you dispose a dialog and the previous form is a dialog it will show that dialog. The problem is that now the "previous" dialog thinks its previous form was the other dialog and that can create an infinite loop of one dialog showing the previous one...
Generally we also try to avoid infinite progress dialog in newer UIs. I didn't like it when we added it but it was a common UI paradigm at the time. E.g. if you look in the new settings UI what we do is just add the InfiniteProgress
into the user interface to indicate we're working. The rest of the UI is still usable during this time which is pretty cool. If a specific button should be disabled we just use setEnabled(false)
instead. This makes the app feel more responsive.
E.g. check out this post: https://www.codenameone.com/blog/data-loading-placeholders.html and this older post https://www.codenameone.com/blog/dont-block-the-ui.html
That's really informative thanks a lot. I will definitely overhaul lots of code now that I know this
My initial question still haunts me because AnimatedDialod
derives from Container
, so I am still unsure how it fits into this
To be honest I haven't seen this error in a while and after what you've said it sounds like it shouldn't happen. I wonder if it was related to a different network error in my app that I recently fixed. I will close this for now to tidy up issues a bit. If it comes back I will reopen
Got some more news... the error happened again a couple of times
It happened when showing a standard Dialog
with a Form
with a Browser
in the background (no other Dialog
or AnimateDialog
opened at the time)
The error got thrown when invoking showPacked(BorderLayout.CENTER, true);
Edit: if I try it on my device I don't see the error so it must be a race condition/device specific etc
Error now happening with somewhat different stack trace. What the errors have in common is that a BrowserComponent is in the center of the Form
_08-13 10%3A17%3A33.442 4006 4044 W System.err%3A java.lang.NullPointerException%3A Attempt to invoke virtual method android.view.ViewGroup%24LayoutParams android.view.View.getLayoutParams() on a null object reference 08-13 10%3A17%3A33.447 4006 4044 W System.err%3A at com.codename1.impl.android.a.a(AndroidAsyncView.java%3A335) 08-13 10%3A17%3A33.447 4006 4044 W System.err%3A at com.codename1.impl.android.f.a(AndroidImplementation.java%3A3929) 08-13 10%3A17%3A33.448 4006 4044 W System.err%3A at com.codename1.w.s.l(Display.java%3A1155) 08-13 10%3A17%3A33.448 4006 4044 W System.err%3A at com.codename1.w.aq.run(RunnableWrapper.java%3A120) 08-13 10%3A17%3A33.448 4006 4044 W System.err%3A at com.codename1.impl.b%241.run(CodenameOneThread.java%3A60) 08-13 10%3A17%3A33.448 4006 4044 W System.err%3A at java.lang.Thread.run(Thread.java%3A784)_
Here is the full stack trace, originating from
Dialog blockScreen = new InfiniteProgress().showInfiniteBlocking();
_07-17 02%3A04%3A46.982 7653 7681 W System.err%3A java.lang.NullPointerException%3A Attempt to invoke virtual method android.view.ViewGroup%24LayoutParams android.view.View.getLayoutParams() on a null object reference 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.impl.android.a.a(AndroidAsyncView.java%3A409) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.impl.android.f.a(AndroidImplementation.java%3A1650) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.impl.a.t(CodenameOneImplementation.java%3A644) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.w.s.m(Display.java%3A1249) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.w.s.k(Display.java%3A1015) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.w.x.a(Form.java%3A2356) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.w.r.a(Dialog.java%3A1138) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.w.r.a(Dialog.java%3A582) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.w.r.a(Dialog.java%3A1439) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.w.r.b(Dialog.java%3A1355) 07-17 02%3A04%3A47.058 7653 7681 W System.err%3A at com.codename1.g.d.d(InfiniteProgress.java%3A182)
This happens very rarely but consistently