You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2020/06/09 23:48:43 UTC
[cordova-android] branch master updated: breaking: reduce combined
response cutoff to 16 MB (#987)
This is an automated email from the ASF dual-hosted git repository.
brodybits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-android.git
The following commit(s) were added to refs/heads/master by this push:
new dead4b4 breaking: reduce combined response cutoff to 16 MB (#987)
dead4b4 is described below
commit dead4b4ab6f0aea37bed5cdb0b9a3b3dcd94698d
Author: Chris Brody <ch...@gmail.com>
AuthorDate: Tue Jun 9 19:48:33 2020 -0400
breaking: reduce combined response cutoff to 16 MB (#987)
* breaking: reduce combined response cutoff to 16 MB
* rename `MAX_PAYLOAD_SIZE` to `COMBINED_RESPONSE_CUTOFF`
* update some comments
* cleanup: split `if` statements into multiple lines
---
.../org/apache/cordova/NativeToJsMessageQueue.java | 24 +++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
index d17b1c4..311ba44 100755
--- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
+++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
@@ -36,10 +36,11 @@ 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.
- // 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 = 50 * 1024 * 10240;
+ // A hopefully reasonable upper limit of how much combined payload data
+ // to send to the JavaScript in one shot.
+ // This currently only chops up on message boundaries.
+ // It may be useful to split and reassemble response messages someday.
+ private static int COMBINED_RESPONSE_CUTOFF = 16 * 1024 * 1024;
/**
* When true, the active listener is not fired upon enqueue. When set to false,
@@ -124,7 +125,10 @@ public class NativeToJsMessageQueue {
/**
* Combines and returns queued messages combined into a single string.
- * Combines as many messages as possible, while staying under MAX_PAYLOAD_SIZE.
+ *
+ * Combines as many messages as possible, without exceeding
+ * COMBINED_RESPONSE_CUTOFF in case of multiple response messages.
+ *
* Returns null if the queue is empty.
*/
public String popAndEncode(boolean fromOnlineEvent) {
@@ -140,7 +144,10 @@ public class NativeToJsMessageQueue {
int numMessagesToSend = 0;
for (JsMessage message : queue) {
int messageSize = calculatePackedMessageLength(message);
- if (numMessagesToSend > 0 && totalPayloadLen + messageSize > MAX_PAYLOAD_SIZE && MAX_PAYLOAD_SIZE > 0) {
+ if (numMessagesToSend > 0 &&
+ COMBINED_RESPONSE_CUTOFF > 0 &&
+ totalPayloadLen + messageSize > COMBINED_RESPONSE_CUTOFF
+ ) {
break;
}
totalPayloadLen += messageSize;
@@ -175,7 +182,10 @@ public class NativeToJsMessageQueue {
int numMessagesToSend = 0;
for (JsMessage message : queue) {
int messageSize = message.calculateEncodedLength() + 50; // overestimate.
- if (numMessagesToSend > 0 && totalPayloadLen + messageSize > MAX_PAYLOAD_SIZE && MAX_PAYLOAD_SIZE > 0) {
+ if (numMessagesToSend > 0 &&
+ COMBINED_RESPONSE_CUTOFF > 0 &&
+ totalPayloadLen + messageSize > COMBINED_RESPONSE_CUTOFF
+ ) {
break;
}
totalPayloadLen += messageSize;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org