Terminal.js

Lightweight Screen Buffer

  • Owner: mbebenita/Terminal.js
  • Platform:
  • License::
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Terminal.js

Sadly, there is no conveneint way to perform low overhead text tracing in modern web browsers.
If you are doing printf debugging and have to deal with lots of text data your options are limited:

  1. Use the browser's developer tools console.
  • Opening the developer tools often slows down your application, which is very annoying if you're trying to understand performance problems.
  • Consoles have a ton of features but can't do very simple things well, like handle lots of text. If you write a lot of text to the console, you'll hang the browser.
  1. Write text to the DOM.
  • You can build your own console using HTML elements. This is only slightly better than using the developer tools.
    You're still allocating tons of memory and possibly causing page reflows if you're not careful.
  1. Write your own text view using Canvas 2D.
  • This works fairly well. You can manage your own string buffer and draw a portion of it with Canvas2D text commands.
    The only drawback here is that you have to keep around a bunch of strings in the JS heap, creating memory pressure.
    You can optimize things by only decoding strings when they are needed but then you allocate lots of new strings, which is not idea.
    I spent a lot of time optimizing this, but at the end of the day it's still not cheap.
  1. Pipe the console output to stdout. You can do this in Firefox and Chrome using some perfs and command line arguments. This is a good idea, do this if you can.

  2. Use this library.

  • Text is encoded as a Uint8Array and uploaded to the GPU as a texture where it's then drawn by a fragment shader.
  • Aside from managing the memory of the text buffer, no allocations happen during tracing and rendering.

Demo:

http://mbebenita.github.io/Terminal.js/

Main metrics

Overview
Name With Ownermbebenita/Terminal.js
Primary LanguageTypeScript
Program languageMakefile (Language Count: 3)
Platform
License:
所有者活动
Created At2015-01-05 05:33:18
Pushed At2015-09-12 18:15:07
Last Commit At2015-09-03 16:01:43
Release Count0
用户参与
Stargazers Count26
Watchers Count5
Fork Count0
Commits Count6
Has Issues Enabled
Issues Count0
Issue Open Count0
Pull Requests Count0
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private