Bandwidth issues in Javascript?

Started by
17 comments, last by Infinity8378 7 years, 6 months ago

How am i to load 172KB/frame @30fps

JQuery and JSON are around 0.12MB/s

and i can't think of another random OOE way to load.

Advertisement
What are you talking about? The language does not determine how fast data flows, the hardware and other systems do.

Are you talking about data over a network? Data from disk? Data from one memory source to another?

Also, how are you loading data? Calling a reading function one byte at a time so you incur a massive overhead, or calling a bulk read function?

What are you talking about? The language does not determine how fast data flows, the hardware and other systems do.

Are you talking about data over a network? Data from disk? Data from one memory source to another?

Also, how are you loading data? Calling a reading function one byte at a time so you incur a massive overhead, or calling a bulk read function?

I thought in javascript/HTML5 you had to use query assets scince due to security you can't access anything else?

I have no idea how load the data.

Moving this thread from “Build Systems and Source Control” to “General Programming”.

I have no idea how load the data.


Request them like any other server resource. Something like this perhaps:

var assets = {};
var queued_assets = [
	'images/example.png',
	'sounds/example.ogg',
	?
];

$q.all(
	queued_assets.map( path =>
		$http.get(path).then( response =>
			assets[path] = response.data;
		)
	)
).then(function(){
	log('assets loaded!');
});

Moving this thread from “Build Systems and Source Control” to “General Programming”.

I have no idea how load the data.


Request them like any other server resource. Something like this perhaps:


var assets = {};
var queued_assets = [
	'images/example.png',
	'sounds/example.ogg',
	?
];

$q.all(
	queued_assets.map( path =>
		$http.get(path).then( response =>
			assets[path] = response.data;
		)
	)
).then(function(){
	log('assets loaded!');
});

That looks like lazy loading i need data each frame

What is “the data”? If you need an interactive connection, then websockets are the only other way to go.

What is “the data”? If you need an interactive connection, then websockets are the only other way to go.

It can be offline data it just seemed like that would still load slow like other queries I haven't been able to get offline data to work with HTML canvas

I don't have a web server but I thought it was slower

It's not an Also the 8bits are not an image but a (Lighting+Normal) map holding luminosity.

Basically i map The GI which is 6 combinations plus the hue which is up to 64 combinations to a 216bit color nondithering color space

It's not an image but a brightness (Lighting+Normal) map.

Basically i map The GI which is 6 combinations plus the hue which is up to 64 combinations to a 216bit color nondithering color space

Wait, are you asking how to stream frame data? Using a text protocol like JSON is definitely not the way - use TypedArrays and Buffers to directly decode/copy image data.

For making the requests, definitely do not make a whole new HTTP request for every single frame. HTTP is _slow_ (at worst you have to establish a whole new TCP connection including renogotiation of the channel and TLS, you have to make a whole new request will all headers, get the request re-routed through the server, and then re-encode all response headers and the body). You want a persistent low-overhead connection, e.g. either WebSockets or server-push events (or emulations there-of).

If you're just loading a big chunk of assets, pack them together into a single file so that you're only paying the request/response overhead once. You can use things like zipjs / JSZip or a variety of other solutions to extract individual files out of a larger (compressed) archive.

For decoding, you can also multi-thread your code using WebWorkers if you need an additional speed bump. Some browsers can _actually_ use multiple threads for WebWorkers. Note also that WebWorkers can do their own I/O requests to further assist with resource loading, assuming that processing/decoding and now bandwidth is your biggest bottleneck (e.g. decoding images dumped into JSON files).

Sean Middleditch – Game Systems Engineer – Join my team!

This topic is closed to new replies.

Advertisement