diff --git a/frontend/apps/reader/modules/readerview.lua b/frontend/apps/reader/modules/readerview.lua index b348183d0..59b42df5e 100644 --- a/frontend/apps/reader/modules/readerview.lua +++ b/frontend/apps/reader/modules/readerview.lua @@ -967,10 +967,12 @@ function ReaderView:checkAutoSaveSettings() if not interval then -- no auto save return end + local now_ts = os.time() if now_ts - self.settings_last_save_ts >= interval*60 then self.settings_last_save_ts = now_ts - UIManager:nextTick(function() + -- I/O, delay until after the pageturn + UIManager:tickAfterNext(function() self.ui:saveSettings() end) end diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 465798822..0a628f33f 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -2173,8 +2173,12 @@ function ReaderStatistics:onPageUpdate(pageno) -- We want a flush to db every 50 page turns if self.pageturn_count >= MAX_PAGETURNS_BEFORE_FLUSH then - self:insertDB(self.id_curr_book) - -- insertDB will call resetVolatileStats for us ;) + -- I/O, delay until after the pageturn, but reset the count now, to avoid potentially scheduling multiple inserts... + self.pageturn_count = 0 + UIManager:tickAfterNext(function() + self:insertDB(self.id_curr_book) + -- insertDB will call resetVolatileStats for us ;) + end) end -- Update average time per page (if need be, insertDB will have updated the totals and cleared the volatiles)