From: liwei Date: Sun, 28 Apr 2019 06:49:20 +0000 (+0800) Subject: Support low memory scenario X-Git-Tag: submit/tizen/20190920.002515~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6357cb351c5ad50edb604ddfbecf2a543c16486d;p=platform%2Fframework%2Fweb%2Fwrtjs.git Support low memory scenario When low memory happen, JS side will receive 'OnLowMemory' event, then call api to clear web cache and network cache. Native Side Link: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/211890/ Change-Id: Ib046d2d619297b1643fd033e5f295ba2f7855fb9 Signed-off-by: liwei --- diff --git a/wrt_app/src/runtime.js b/wrt_app/src/runtime.js index 6be68bdb..066b341f 100755 --- a/wrt_app/src/runtime.js +++ b/wrt_app/src/runtime.js @@ -185,6 +185,10 @@ class Runtime { console.log('resume'); _this.webApplication.resume(_this.addonManager.resume_path); }); + wrt.on('low-memory', function() { + console.log('low-memory'); + _this.webApplication.lowMemory(); + }); } handleIpcMessages() { var _this = this; diff --git a/wrt_app/src/web_application.js b/wrt_app/src/web_application.js old mode 100755 new mode 100644 index 721bd175..38b0fc0f --- a/wrt_app/src/web_application.js +++ b/wrt_app/src/web_application.js @@ -405,5 +405,17 @@ class WebApplication { } } } + lowMemory() { + console.log('WebApplication : lowMemory to clearcache'); + if (this.isTVProfile) { + this.windowList.forEach((window) => { + //clear webframe cache + wrt.clearWebCache(window.webContents); + window.webContents.session.clearCache(function() { + console.log('clear session Cache complete'); + }) + }); + } + } } module.exports = WebApplication;