Affects Version/s: 3.5.0
Fix Version/s: None
Android 4.2 + Android 4.4 (presumably others)
I have an app where I'm calling:
from org.apache.cordova.dialogs 0.2.9. The dialog is displayed fine, however on my Android test devices upon pressing a dialog button my callback function sometimes isn't executed. My iOS test devices are fine.
I believe I've tracked this down to an issue with Android's JS implementation, however I don't have quite enough knowledge of Cordova to ascertain the root cause or fix it properly.
Naturally, navigator.notification.confirm calls androidExec. This in turn makes a native API call. The thing I'm unsure about is the following events:
When I press one of the confirm dialog buttons the event listener pollOnceFromOnlineEvent is called, which retrieves messages from the native API and processes them accordingly. However it seems the online event doesn't always work. I'm not sure why we're using the online event in the first place though..
Now, there's a nasty side-effect as well. In androidExec itself, after making the native API call, we actually call processMessages, so we may get our callback, but delayed!
What should happen:
call confirm() --> calls androidExec --> calls processMessages (no messages) --> user button press --> online event --> calls pollOnceFromOnlineEvent --> calls processMessages --> calls callback
What actually happens is:
call confirm() --> calls androidExec --> calls processMessages (no messages) --> user button press --> NO online event
.. time passes ..
call confirm() --> calls androidExec --> calls processMessages (got message!!) --> calls callback --> user button press --> NO online event
.. and the bad cycle continues.
I believe some points to consider are:
- Is the online event being used properly
- The android JS implementation seems to support polling mode - should we be using this?
- Should androidExec be processing messages immediately after the native API call?
I've put this as an issue with 3.5.0, as that's what my app is running and can readily repro it, however it also existed on 3.4.x.