[Service] wasm caching in built-in service 64/230764/23
authorDongHyun Song <dh81.song@samsung.com>
Tue, 14 Apr 2020 06:22:09 +0000 (15:22 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Thu, 21 May 2020 06:14:13 +0000 (06:14 +0000)
This will be a service application working as build WASM caching on
installation time.
Actual implementation will be developed by WASM part.

** WASM caching **

Regarding the performance of creating wasm cache on first loading
time, this patch will take the time on installation time to service
application side.
Service application is first launched while its installation time
by ContentServiceManager of TV component, then it is able to create
wasm cache ahead of UI application run.

However, if a user try to launch the app as soon as it is installed,
this wasm caching is ineffective or raising performance loss by
racing simultaneous generation of cache files.
This is important design point to consider.

Related chromium-efl patch:
  https://review.tizen.org/gerrit/230786/

Change-Id: I9b8c1630ddf22036f4dd98bbe1f962443e589a3f
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt_app/service/builtins/wasm_builder.js [new file with mode: 0644]
wrt_app/service/main.js

diff --git a/wrt_app/service/builtins/wasm_builder.js b/wrt_app/service/builtins/wasm_builder.js
new file mode 100644 (file)
index 0000000..ff41f64
--- /dev/null
@@ -0,0 +1,17 @@
+const wrt = require('../../browser/wrt');
+
+function run(app_id) {
+    console.log('wasm_builder.js start');
+    // sample
+    /*
+    let files = wrt.tv.enumerateWasmFiles(app_id);
+    files.forEach((file_path) => {
+      console.log(`file_path: ${file_path}`);
+      require(`${file_path}`);
+    });
+    */
+}
+
+module.exports = {
+  run
+}
\ No newline at end of file
index 2cf534f..03d86b7 100755 (executable)
@@ -31,6 +31,31 @@ wrt.on('stop-service', (event, internal_id) => {
     process.exit();
 });
 
+wrt.on('builtin-service', (event, internal_id, service_name) => {
+    console.log(`service_name: ${service_name}`);
+    const vm = require('vm');
+    let builtin_service = '';
+    if (service_name === 'wasm_builder') {
+      builtin_service = './builtins/wasm_builder.js';
+    }
+    if (builtin_service) {
+      console.log(`Builtin service is ${builtin_service}`);
+      let sandbox = {
+          console: console,
+          require: require,
+      };
+      let options = {
+        filename: internal_id,
+      };
+      let code = `require('${builtin_service}').run('${internal_id}')`;
+      vm.runInNewContext(code, sandbox, options);
+    }
+});
+
+wrt.on('quit', (event) => {
+    process.exit();
+});
+
 process.on('exit', (code) => {
   console.log('Exit with code : ' + code);
 });