Skip to content

Commit

Permalink
Disable limiting of payload size when sending data to JS.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrieve committed Oct 26, 2012
1 parent e4f8f44 commit 678ae2d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions framework/src/org/apache/cordova/NativeToJsMessageQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ public class NativeToJsMessageQueue {
// exec() is asynchronous. Set this to true when running bridge benchmarks.
static final boolean DISABLE_EXEC_CHAINING = false;

// Arbitrarily chosen upper limit for how much data to send to JS in one shot.
private static final int MAX_PAYLOAD_SIZE = 50 * 1024;
// Upper limit for how much data to send to JS in one shot.
// TODO(agrieve): This is currently disable. It should be re-enabled once we
// remove support for returning values from exec() calls. This was
// deprecated in 2.2.0.
// Also, this currently only chops up on message boundaries. It may be useful
// to allow it to break up messages.
private static int MAX_PAYLOAD_SIZE = -1; //50 * 1024 * 10240;

/**
* The index into registeredListeners to treat as active.
Expand Down Expand Up @@ -144,7 +149,7 @@ public String popAndEncode() {
int numMessagesToSend = 0;
for (JsMessage message : queue) {
int messageSize = calculatePackedMessageLength(message);
if (numMessagesToSend > 0 && totalPayloadLen + messageSize > MAX_PAYLOAD_SIZE) {
if (numMessagesToSend > 0 && totalPayloadLen + messageSize > MAX_PAYLOAD_SIZE && MAX_PAYLOAD_SIZE > 0) {
break;
}
totalPayloadLen += messageSize;
Expand Down Expand Up @@ -178,7 +183,7 @@ private String popAndEncodeAsJs() {
int numMessagesToSend = 0;
for (JsMessage message : queue) {
int messageSize = message.calculateEncodedLength() + 50; // overestimate.
if (numMessagesToSend > 0 && totalPayloadLen + messageSize > MAX_PAYLOAD_SIZE) {
if (numMessagesToSend > 0 && totalPayloadLen + messageSize > MAX_PAYLOAD_SIZE && MAX_PAYLOAD_SIZE > 0) {
break;
}
totalPayloadLen += messageSize;
Expand Down

0 comments on commit 678ae2d

Please sign in to comment.