Bug 1497526 - TransactionTooLargeException when downloading from Data URLs. r=jchen, a=pascalc
authorPetru Lingurar <petru.lingurar@softvision.ro>
Fri, 26 Oct 2018 07:39:01 +0000
changeset 492968 ea5bceb1d4ac
parent 492967 b71bed0c6a40
child 492969 7247a70272a2
push id1844
push userryanvm@gmail.com
push dateMon, 05 Nov 2018 15:21:08 +0000
treeherdermozilla-release@805f775f35e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, pascalc
Bug 1497526 - TransactionTooLargeException when downloading from Data URLs. r=jchen, a=pascalc 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;