Support low memory scenario 35/204835/13
authorliwei <wei90727.li@samsung.com>
Sun, 28 Apr 2019 06:49:20 +0000 (14:49 +0800)
committerSangYong Park <sy302.park@samsung.com>
Tue, 3 Sep 2019 00:46:41 +0000 (00:46 +0000)
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 <wei90727.li@samsung.com>
wrt_app/src/runtime.js
wrt_app/src/web_application.js [changed mode: 0755->0644]

index 6be68bd..066b341 100755 (executable)
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
index 721bd17..38b0fc0
@@ -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;