[
https://issues.apache.org/jira/browse/CB-6761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14015832#comment-14015832
]
Clayton Grassick commented on CB-6761:
--------------------------------------
Changing bridge modes didn't work out so good. There's a reason we are using
OnlineEvents.
I did get myself out of the pickle by changing the code in
NativeToJsMessageQueue.java to:
{noformat}
/** Uses online/offline events to tell the JS when to poll for messages. */
private class OnlineEventsBridgeMode extends BridgeMode {
final Runnable runnable = new Runnable() {
public void run() {
if (!queue.isEmpty()) {
webView.setNetworkAvailable(true);
}
}
};
final Runnable runnableFlush = new Runnable() {
public void run() {
webView.setNetworkAvailable(false);
}
};
@Override void reset() {
webView.setNetworkAvailable(false);
}
@Override void onNativeToJsMessageAvailable() {
cordova.getActivity().runOnUiThread(runnable);
}
// Track when online/offline events are fired so that we don't fire
excess events.
@Override void notifyOfFlush(boolean fromOnlineEvent) {
if (fromOnlineEvent) {
cordova.getActivity().runOnUiThread(runnableFlush);
}
}
}
{noformat}
I have no more bad behavior, but I don't have the deeper knowledge of the
bridges to see if my solution has its own flaws. At least I can release my
update for now.
> Calling a function the first time no callbacks are being executed
> -----------------------------------------------------------------
>
> Key: CB-6761
> URL: https://issues.apache.org/jira/browse/CB-6761
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android, CordovaJS
> Affects Versions: 3.5.0
> Environment: Nexus 5, Android 4.4.2
> Reporter: Roy Ackermann
> Priority: Blocker
> Labels: bridge, callback, function
>
> Using different functions the same error occurs. Calling a function the first
> time no callbacks are being executed. There is no error in the log. Using the
> same function again for a second call, everything works fine. Now the first
> call is being executed as well and I receive the callback from the first
> excution.
> It looks like something is wainting. It is odd that the second call works and
> executes the first call as well.
> I found this bug on this calls:
> - window.requestFileSystem(LocalFileSystem.PERSISTENT, 3097152, gotFS, fail);
> - navigator.camera.getPicture(onSuccessCapturePhoto, onFailCamera, {
> targetWidth: 1200, targetHeight: 1200, quality: 55, destinationType:
> Camera.DestinationType.FILE_URI, saveToPhotoAlbum: true,
> correctOrientation:true});
> - navigator.camera.getPicture(onSuccessGetPhoto, onFailCamera, { targetWidth:
> 1000,targetHeight: 1000, quality: 65, destinationType:
> Camera.DestinationType.FILE_URI , saveToPhotoAlbum: false , sourceType:
> Camera.PictureSourceType.SAVEDPHOTOALBUM, correctOrientation:true});
--
This message was sent by Atlassian JIRA
(v6.2#6252)