]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/asynctasks/SaveUrl.java
Fix downloads consuming massive CPU and locking the UI on slower CPUs. https://redmin...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / asynctasks / SaveUrl.java
index 7d981c0f324a554cded0809515aca0c578a8fdbd..c93070951eeb352d380b90590fac9d53f230d4b0 100644 (file)
@@ -170,7 +170,8 @@ public class SaveUrl extends AsyncTask<String, Long, String> {
                     InputStream inputStream = new BufferedInputStream(httpUrlConnection.getInputStream());
 
                     // Initialize the conversion buffer byte array.
-                    byte[] conversionBufferByteArray = new byte[1024];
+                    // This is set to a megabyte so that frequent updating of the snackbar doesn't freeze the interface on download.  <https://redmine.stoutner.com/issues/709>
+                    byte[] conversionBufferByteArray = new byte[1048576];
 
                     // Initialize the downloaded kilobytes counter.
                     long downloadedKilobytesCounter = 0;
@@ -198,9 +199,6 @@ public class SaveUrl extends AsyncTask<String, Long, String> {
                 }
             }
 
-            // Flush the output stream.
-            outputStream.flush();
-
             // Close the output stream.
             outputStream.close();
         } catch (Exception exception) {