Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove pollOnce from NativeToJsMessageQueue.popAndEncodeAsJs #1746

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

erisu
Copy link
Member

@erisu erisu commented Nov 13, 2024

Motivation and Context

Remove the require block for cordova/plugin/android/polling, a module that doesn't exist.

Resolves #1735

Description

The cordova/plugin/android/polling module appears to have been removed since 2012.

The last known version of Cordova-JS where this module existed was [email protected] - polling.js in the polling.js file, with the version tag created on Sep 13, 2012.

The module was removed in [email protected], a tag/release created on Oct 16, 2012.

The exact commit that removed the module from Cordova-JS does not have an associated PR, GitHub issue, or CB ticket to explain the reason for this change.

Additionally, the platform-specific Cordova-JS modules, which reside in the cordova-js-src directory of this repository (originally labeled as platform_modules), were not created until 2015—2 years and 4 months later. This directory has also never contained the polling module as far as I can see.

Since this part of the code has not been functional since 2012, I believe it is safe to remove it.

Testing

n/a

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@dpogue
Copy link
Member

dpogue commented Nov 13, 2024

I believe the polling implementation was brought into the main exec file, and still exists here:

function pollOnce (opt_fromOnlineEvent) {
if (bridgeSecret < 0) {
// This can happen when the NativeToJsMessageQueue resets the online state on page transitions.
// We know there's nothing to retrieve, so no need to poll.
return;
}
var msgs = nativeApiProvider.get().retrieveJsMessages(bridgeSecret, !!opt_fromOnlineEvent);
if (msgs) {
messagesFromNative.push(msgs);
// Process sync since we know we're already top-of-stack.
processMessages();
}
}

I don't know whether that means we should be calling it from Java or not... clearly this has been broken for a long while

@erisu
Copy link
Member Author

erisu commented Nov 13, 2024

I believe the polling implementation was brought into the main exec file, and still exists here:

function pollOnce (opt_fromOnlineEvent) {
if (bridgeSecret < 0) {
// This can happen when the NativeToJsMessageQueue resets the online state on page transitions.
// We know there's nothing to retrieve, so no need to poll.
return;
}
var msgs = nativeApiProvider.get().retrieveJsMessages(bridgeSecret, !!opt_fromOnlineEvent);
if (msgs) {
messagesFromNative.push(msgs);
// Process sync since we know we're already top-of-stack.
processMessages();
}
}

I don't know whether that means we should be calling it from Java or not... clearly this has been broken for a long while

Might be able to expose that method by added it to androidExec:

androidExec.pollOnce = pollOnce;

Then instead of deleting the line, update it to:

            if (!willSendAllMessages) {
                sb.append("window.setTimeout(function(){cordova.require('cordova/exec').pollOnce();},0);");
            }

But I don't know what the behavior it will have after adding a pollOnce call to something that never ran for 12 years...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

module cordova/plugin/android/polling not found
2 participants