Using Web Workers for drawing using native canvas functions

[Edit ~5 years later: some of this is beginning to change, and there are new web platform features that actually allow rendering to a canvas from a Worker! See this blog for more info: https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/ – the rest of the answer is provided for 2011-era information ;)] Web workers can only calculate, not modify the … Read more

JavaScript: How to know if a connection with a shared worker is still alive?

This is only as reliable as beforeunload, but seems to work (tested in Firefox and Chrome). I definitely favour it over a polling solution. // Tell the SharedWorker we’re closing addEventListener( ‘beforeunload’, function() { port.postMessage( {command:’closing’} ); }); Then handle the cleanup of the port object in the SharedWorker. e.ports[0].onmessage = function( e ) { … Read more

Why was HTML5 Web Workers support removed from the Android browser in versions 2.2 and up?

from config.h of Android 2.2. commit 68698168e7547cc10660828f1fb82be7a8efa845 Author: Steve Block Date: Wed Mar 17 14:37:19 2010 +0000 Disable workers This is because V8 on Android does not have the required locking. Also disables channel messaging, which is used only with workers. Bug: 2522239 Change-Id: I6cb91b4048c7e1a0351e422561625397a2e98986 via http://code.google.com/p/android/issues/detail?id=10004#c7

Web Workers vs Promises

`Deferred/Promises and Web Workers address different needs: Deferred/promise are constructs to assign a reference to a result not yet available, and to organize code that runs once the result becomes available or a failure is returned. Web Workers perform actual work asynchronously (using operating system threads not processes – so they are relatively light weight). … Read more

using WebAssembly in chrome extension

I’ve been fiddling with WebAssembly recently, and found a way to make it work. Here are the script files: main.js chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.executeScript(null, {file: “content_script.js”}); }); content_script.js var importObject = { imports: { imported_func: arg => console.log(arg) } }; url=”data:application/wasm;base64,” + “AGFzbQEAAAABCAJgAX8AYAAAAhkBB2ltcG9ydHMNaW1wb3J0ZWRfZnVuYwAAAwIBAQcRAQ1leHBvcnRlZF9mdW5jAAEKCAEGAEEqEAAL”; WebAssembly.instantiateStreaming(fetch(url), importObject) .then(obj => obj.instance.exports.exported_func()); The data URL belongs to the common tutorial … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)