From 911391ea2fd26a7145c4e6c830590624f19b91a6 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 22 Sep 2018 13:37:25 +0000 Subject: [PATCH] Yield after message/batch --- .../eu/faircode/email/ServiceSynchronize.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 116943ccfa..7145383d38 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1542,6 +1542,7 @@ public class ServiceSynchronize extends LifecycleService { db.beginTransaction(); ids[from + j] = synchronizeMessage(this, folder, ifolder, (IMAPMessage) isub[j], false); db.setTransactionSuccessful(); + Thread.sleep(20); } catch (MessageRemovedException ex) { Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); } catch (FolderClosedException ex) { @@ -1555,6 +1556,11 @@ public class ServiceSynchronize extends LifecycleService { // Reduce memory usage ((IMAPMessage) isub[j]).invalidateHeaders(); } + + try { + Thread.sleep(100); + } catch (InterruptedException ignored) { + } } db.folder().setFolderState(folder.id, "downloading"); @@ -1573,8 +1579,10 @@ public class ServiceSynchronize extends LifecycleService { for (int j = isub.length - 1; j >= 0; j--) try { //Log.i(Helper.TAG, folder.name + " download index=" + (from + j) + " id=" + ids[from + j]); - if (ids[from + j] != null) + if (ids[from + j] != null) { downloadMessage(this, folder, ifolder, (IMAPMessage) isub[j], ids[from + j]); + Thread.sleep(20); + } } catch (FolderClosedException ex) { throw ex; } catch (FolderClosedIOException ex) { @@ -1585,6 +1593,11 @@ public class ServiceSynchronize extends LifecycleService { // Free memory ((IMAPMessage) isub[j]).invalidateHeaders(); } + + try { + Thread.sleep(100); + } catch (InterruptedException ignored) { + } } } finally {