Bug 1497526 - TransactionTooLargeException when downloading from Data URLs. r=jchen, a=RyanVM
authorPetru Lingurar <petru.lingurar@softvision.ro>
Fri, 26 Oct 2018 07:39:01 +0000
changeset 498224 f9da620994ae1a1cf533882625c1777af07f56c3
parent 498223 c96f6ed751bf51a86d910aad441c3b1538f674a7
child 498225 1bef24401c99d6375d189430885044fa77824818
push id10076
push userryanvm@gmail.com
push dateWed, 31 Oct 2018 15:37:36 +0000
treeherdermozilla-beta@f9da620994ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, RyanVM
Bug 1497526 - TransactionTooLargeException when downloading from Data URLs. r=jchen, a=RyanVM The issue stems from putting download's source url as `cookie` in the pending intent for when the download notification is clicked. This cookie functions like a tag, allowing to identify a particular download. The problem is that a download's url can be a Data URL for which Mozilla imposes no size limit. When an Android Intent with that payload is used it counts against Binder's 1MB limit which can result in the TransactionTooLargeException. If we are to truncate download's source url to an arbitrary length of 100 we should still get a unique `cookie` for that download and at the same time avoid cluttering Notification's contentIntent. Differential Revision: https://phabricator.services.mozilla.com/D9666
--- a/mobile/android/modules/DownloadNotifications.jsm
+++ b/mobile/android/modules/DownloadNotifications.jsm
@@ -175,18 +175,20 @@ var DownloadNotifications = {
 function getCookieFromDownload(download) {
+  // Arbitrary value used to truncate long Data URLs. See bug 1497526
+  const maxUrlLength = 1024;
   return download.target.path +
-         download.source.url +
+         download.source.url.slice(-maxUrlLength) +
 function DownloadNotification(download) {
   this.download = download;
   this._fileName = OS.Path.basename(download.target.path);
   this.id = null;