javascript - Google Chrome App: Webview behavior -


while researching issue on <iframe> on chrome extension, <webview> in chrome apps caught eye , got me interested.

so decided small example of issue facing on <iframe> , see if <webview> solved. understood of watching chrome dev video, webview runs in separate process app; doesn't have same permissions app. assume if content in runs in way separated 'main thread' (app), guess content executed separately each other not blocking app or other in case of them have possible long running js executon. therefore did following:

background.js

chrome.app.runtime.onlaunched.addlistener(function() {   // tell app launch , how.   chrome.app.window.create('window.html', {       width: 1800,       height: 1000   }); }); 

manifest.json

{   // required   "name": "hello world!",   "version": "0.1",   "manifest_version": 2,    // recommended   "description": "my first packaged app.",   "icons": { "16": "calculator-16.png", "128": "calculator-128.png" },   // "default_locale": "en",    // pick 1 (or none) of browser_action, page_action, theme, app     "app": {     "background": {       "scripts": [ "background.js" ]     }   },    "minimum_chrome_version": "23",    "permissions": [ "webview" ]  } 

window.html

<!doctype html> <html>   <head>   </head>   <body>     <div>hello, world!</div>     <webview id="wv1" style="width: 450px; height: 300px; border: 2px solid red" src="http://www.google.com"></webview>     <webview id="wv2" style="width: 450px; height: 300px; border: 2px solid red" src="http://www.nytimes.com"></webview>     <webview id="wv3" style="width: 450px; height: 300px; border: 2px solid red" src="http://www.stackoverflow.com"></webview>     <webview id="wv4" style="width: 450px; height: 300px; border: 2px solid red" src="http://db.tt/fcca7nuz"></webview>   </body> </html> 

three of webviews normal webpages, fouth example of long running js file, can inspect code or can provide later. if open 4 google chrome browser windows, type address, press enter, observe is: 3 pages loaded imediately , other long js execution still working.

if in webpage, using open these 4 webpages, since in same process, if 1 page slow/blocks due js execution, others blocked.

now chrome app, using noticed interesting , weird behavior. notice following:

  1. if load first 3 webpages, load fast , 'at same time' or appears;
  2. if load webpages is, see first 3 pages loading , last since has long js execution takes time , shows (this optimal behavior), since different proccesses shouldn't depend on if webview slow, others must wait;
  3. now if comment third , refresh , execute app, see no webview until 1 longscript done. (why happens?)
  4. the point above random either happens mentioned or doesn't.
  5. and last, let's add <webview id="wv5" style="width: 450px; height: 300px; border: 2px solid red" src="http://developer.chrome.com"></webview>, happen me is: first 3 loaded, fourth executing , after finished , displayed see fifth rendered.

my main question/doubt around behavior , since running in separate process, why doesn't have same behavious browser window example, why webview blocks others working/rendering, intended work is? should workaround detect if webview after time isn't finished skip load , let others load go slow ones?

thank in advance.

webviews run in different process app, run in same process of each other in same partition. if don't specify partition attribute, in same, default one. if check chrome task manager (shift+esc) see: enter image description here

(notice process id column)

if instead set each webview different partition using tag attribute:

<!doctype html> <html>   <head>   </head>   <body>     <div>hello, world!</div>     <webview id="wv1" partition="p1" style="width: 450px; height: 300px; border: 2px solid red" src="http://www.google.com"></webview>     <webview id="wv2" partition="p2" style="width: 450px; height: 300px; border: 2px solid red" src="http://www.nytimes.com"></webview>     <webview id="wv3" partition="p3" style="width: 450px; height: 300px; border: 2px solid red" src="http://www.stackoverflow.com"></webview>     <webview id="wv4" partition="p4" style="width: 450px; height: 300px; border: 2px solid red" src="http://db.tt/fcca7nuz"></webview>   </body> </html> 

you see each webview runs in own process:

enter image description here


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -