-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image support #2503
Closed
+3,010
−105
Closed
image support #2503
Changes from all commits
Commits
Show all changes
162 commits
Select commit
Hold shift + click to select a range
b2352ea
working sixel draft
jerch 11b1458
fix linter and @types/node dep
jerch 4f31ba9
install addon deps in CI
jerch 435e2c4
fix linter error from addon dep
jerch aa11cfa
Merge branch 'master' into addon-images
jerch 81946b1
Merge branch 'master' into addon-images
jerch 502562e
Merge branch 'addon_build' into addon-images
jerch 02c55d8
revert CI pipeline changes
jerch 912ccb3
restrict linter to addons/*/src files
jerch 9540037
Merge branch 'addon_build' into addon-images
jerch 2a6d4f0
Merge branch 'addon_build' into addon-images
jerch c65f676
Merge branch 'master' into addon-images
jerch 3c5c8be
Merge branch 'master' into addon-images
jerch e147673
3x speedup with low level SIXEL handler
jerch e128e40
Merge branch 'addon-images' of github.com:jerch/xterm.js into addon-i…
jerch b17dc31
Merge branch 'master' into addon-images
jerch b1193aa
fix incompatible type declaration
jerch 091c421
make linter happy
jerch 715143c
use ImageBitmap internally, remove different renderer hacks
jerch ab63ddd
Merge remote-tracking branch 'upstream/master' into addon-images
jerch 750a077
Merge branch 'master' into addon-images
jerch dfc1ddc
Merge branch 'master' into addon-images
jerch 988c384
remove marker overload
jerch 4a6ba2b
Merge branch 'master' into addon-images
jerch 9c79dff
own imagerenderer layer to work with all render types
jerch f981f13
- sixel handler init with params
jerch 9f90781
Merge branch 'master' into addon-images
jerch a67b81b
fix tsconfig issues
jerch eb52952
refactor to a more modular approach
jerch 9e3f284
multiple changes:
jerch 8954f17
changes:
jerch fa29fc9
update readme and exported types
jerch d7a4991
changes:
jerch 3bf8e62
Merge branch 'master' into addon-images
jerch 80e77ef
fix eslint OOM by merging tsconfig lookups
jerch ba2d27c
skip failing test for now
jerch 9a67407
fix leftover artefacts on image layer
jerch a32a2d1
add DA1 overload and xterm GA sequence, fix SIXEL bg handling
jerch 1a2066e
implement a max size storage limit with hard eviction rule
jerch 00e8ade
add placeholder option for deleted images
jerch df48f27
couple of eviction rules:
jerch 896dfd1
expose some settings on demo page
jerch 2399310
add sixel example file
jerch 07a2d24
multiple WIP changes:
jerch b57646f
quickhack to export image as blob on ctrl+click
jerch 18855d1
Merge branch 'master' into addon-images
jerch 43f84c1
fix changed handler hook
jerch 8a8fcbd
fix linter
jerch d8fef13
Merge branch 'master' into addon-images
jerch dbba13b
Merge branch 'master' into addon-images
jerch 6d8bd8a
remove iTerm2 support and own protocol draft
jerch 1ff4799
add example pictures as fixtures
jerch daf3a58
make linter happy
jerch 82cbbd1
worker based sixel decoding
jerch eeeb8f6
Merge branch 'master' into addon-images
jerch 411078c
use proper type inference on messages
jerch 4180f6e
better worker integration:
jerch 9514225
basic private accessor test
jerch ced99a5
update addon requirements, fix bundling
jerch 346e232
remove click hack, doc next steps
jerch 8522b90
fix type exports and README
jerch db9bfc5
layout few more next steps
jerch 46473ff
remove some of the private hacks
jerch a0b5fa9
fix tsconfig paths in test project
jerch c09128a
kiss - remove storage remnants from iterm image protocols
jerch c9337f8
better typing, optimized ExtendedAttrsImage creation
jerch 0fd64ee
expose cell metrics internally
jerch 7e0e54c
explicit test for buffer and attribute private access
jerch 6993f4d
Merge branch 'master' into addon-images
jerch 4b14446
add comment about garbage on screen
jerch 143f113
Merge branch 'master' into addon-images
jerch 5a6f3a7
make linter happy
jerch e054ec7
change integration test port to 3001
jerch 0b3aa46
Merge branch 'master' into addon-images
jerch 7166bf6
fix Promise<void>
jerch 736fc31
fix mocha timeout error
jerch 7de2430
Merge branch 'master' into addon-images
jerch 58e3c6e
fix safari render bug
jerch c2c753e
add banding test
jerch e0f23d2
custom setting to fit oversized images to viewport width
jerch 005648c
apply eviction after rescaling to avoid wrong image accounting
jerch c98eb8f
growing rectangle test without flickering
jerch b98c126
skip undefined image eAttr in render
jerch 61c5615
fix DOM renderer rescaling issue
jerch e0d7b3e
onResize hook for right expansion
jerch c145c63
make linter happy
jerch 8887564
Merge branch 'master' into addon-images
jerch 0d9a543
fix marker memory leak
jerch dfa8b84
remove <TypeX>yz casts
jerch 69e9779
cleanup fitOversizedToViewportWidth
jerch 4c0a5d4
use transferable pixel buffer
jerch 124c603
fix type casts
jerch 019986e
Merge branch 'master' into addon-images
jerch 1e2f24e
Merge branch 'master' into addon-images
jerch f2a8556
Merge branch 'master' into addon-images
jerch f755ac4
activate windowOptions on addon load, polish docs
jerch c9fe4f1
Merge branch 'addon-images' of github.com:jerch/xterm.js into addon-i…
jerch ebc7145
basic image data retrieval API
jerch 18c898b
limit pixels for single image
jerch 84071e3
cleanup FIXMEs
jerch 90864c5
fix integration tests
jerch 28e14b6
multiple mostly cleanup changes:
jerch 708517e
revert false simplification
jerch b8f6c26
minor fixes
jerch 10ba35f
change eslint project settings
jerch 3eedf92
Merge branch 'master' into addon-images
jerch 4a89f15
Merge branch 'master' into addon-images
jerch dfc7e23
fix private coreService access
jerch 8c09894
Merge branch 'master' into addon-images
jerch 32adff2
remove leftover .only in test suite
jerch ded80b3
Merge branch 'master' into addon-images
jerch 652e03a
Merge branch 'master' into addon-images
jerch db8eb2b
update to new sixel decoder
jerch 73459d6
Merge branch 'addon-images' of github.com:jerch/xterm.js into addon-i…
jerch 27218f6
Merge branch 'master' into addon-images
jerch 16eb95a
fix yarn.lock to point to right version
jerch 5a0939d
Merge branch 'master' into addon-images
jerch a4587f9
Merge branch 'master' into addon-images
jerch 6676dec
cleanup fixtures
jerch ce499d1
remove dispose from readme example
jerch 85d8d73
add demo buttons
jerch 7ed3c48
fix xterm dep version
jerch 3ae28d2
simplify worker message types
jerch cd1448b
add example image to readme
jerch 0277697
use star comments in typings
jerch 07bc129
use import type, fix pixel limit, remove cmdline bookmarks
jerch 3b720fe
Merge branch 'addon-images' of github.com:jerch/xterm.js into addon-i…
jerch c9f27a8
make linter happy
jerch f128c04
Merge branch 'master' into addon-images
jerch 87365f1
flip DECSET 80 & 7730 settings
jerch 14b4d4c
fix cursor positioning tests
jerch 09ffed4
fix cursor positioning tests
jerch 276d291
reduce perma held memory for sixel decoding to 4MB
jerch 99e4072
report true window area for sixel geo read if within pixelLimit
jerch 7f003fe
use famous snake sixel example image from libsixel repo
jerch aaef0fd
widen type to HTMLElement
jerch bfa0de7
update xterm peer dep version
jerch e073d8b
make workerPath mandatory
jerch 918113f
fix page eval in api test
jerch 5c64048
remove TODO list from source code
jerch 488cddc
change pixelLimit description
jerch b9969e9
simplify partial addon options
jerch f712933
simplify private interface imports from repo base
jerch ba07f6f
use arrow functions in API tests
jerch 9199b53
use helper for test startup
jerch ad914a8
shorten private accessor tests
jerch 85c0df0
rename Dim to Dimensions
jerch 8eaeb1e
use const enum for worker message type
jerch 9c2caf0
rename clearCheckerInterval, use shorthand notation for promise return
jerch c1cb794
fix _poolCheckerInterval name access in test
jerch dd8050a
fix _poolCheckerInterval name access in test
jerch 336ef5e
Merge branch 'master' into addon-images
jerch d882cef
fix reported canvas size, rounding fix in XTSMGRAPHICS
jerch 47412ec
Merge branch 'master' into addon-images
jerch 6da04ff
Merge branch 'master' into addon-images
jerch ba50ec6
Merge branch 'master' into addon-images
jerch 7b1fcad
Merge branch 'master' into addon-images
jerch bc1f1d4
fix unknown type in catch
jerch 74d12d1
Merge branch 'master' into addon-images
jerch 9468d0d
fix shared palette handling
jerch 55db19c
use enum for ack payload
jerch 414172c
Merge branch 'master' into addon-images
jerch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es2017", | ||
"rootDir": ".", | ||
"outDir": "../out-test", | ||
"sourceMap": true, | ||
"removeComments": true, | ||
"strict": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"browser/*": [ "../../../src/browser/*" ], | ||
"common/*": [ "../../../src/common/*" ] | ||
}, | ||
"types": [ | ||
"../node_modules/@types/mocha", | ||
"../node_modules/@types/node", | ||
"../out-test/api/TestUtils" | ||
] | ||
}, | ||
"include": [ | ||
"../typings/xterm.d.ts", | ||
"./**/src/*", | ||
"./**/src-worker/*", | ||
"./**/test/*", | ||
"./**/benchmark/*" | ||
], | ||
"references": [ | ||
{ "path": "../src/browser" }, | ||
{ "path": "../src/common" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lib | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
**/*.api.js | ||
**/*.api.ts | ||
tsconfig.json | ||
.yarnrc | ||
webpack.config.js | ||
|
||
fixture | ||
src | ||
src-worker | ||
test | ||
out-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2019, The xterm.js authors (https://github.com/xtermjs/xterm.js) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
## xterm-addon-image | ||
|
||
Image output in xterm.js. | ||
jerch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
![](fixture/example.png) | ||
|
||
|
||
⚠️ This is an experimental addon, that is still under construction. ⚠️ | ||
|
||
|
||
### Install | ||
|
||
```bash | ||
npm install --save xterm-addon-image | ||
``` | ||
|
||
### Usage | ||
|
||
```ts | ||
import { Terminal } from 'xterm'; | ||
import { ImageAddon, IImageAddonOptions } from 'xterm-addon-image'; | ||
|
||
const WORKER_PATH = '/path/to/xterm-addon-image-worker.js'; | ||
|
||
// customize as needed | ||
const customSettings: IImageAddonOptions = { | ||
sixelSupport: true, | ||
... | ||
} | ||
|
||
// initialization | ||
const terminal = new Terminal(); | ||
const imageAddon = new ImageAddon(WORKER_PATH, customSettings); | ||
terminal.loadAddon(imageAddon); | ||
``` | ||
|
||
### General Notes | ||
|
||
- The image decoding is done with a worker, therefore the addon will only work, if you expose the worker file as well. The worker is distributed under `lib/xterm-addon-image-worker.js`. Place the exported worker path as the first argument of the addon constructor, e.g. `new ImageAddon('/your/path/to/image/worker')`. Additionally make sure, that your main integration has proper read and execution permissions on the worker file, otherwise the addon will log a worker error and disable itself on the first image decoding attempt (lazy evaluated). | ||
|
||
- By default the addon will activate these `windowOptions` reports on the terminal: | ||
- getWinSizePixels (CSI 14 t) | ||
- getCellSizePixels (CSI 16 t) | ||
- getWinSizeChars (CSI 18 t) | ||
|
||
to help applications getting useful terminal metrics for their image preparations. Set `enableSizeReports` in the constructor options to `false`, if you dont want the addon to alter these terminal settings. This is especially useful, if you have very strict security needs not allowing any terminal reports, or deal with `windowOptions` by other means. | ||
|
||
|
||
### Operation Modes | ||
|
||
- **SIXEL Support** | ||
Set by default, change it with `{sixelSupport: true}`. | ||
|
||
- **Scrolling On | Off** | ||
By default scrolling is on, thus an image will advance the cursor at the bottom if needed. | ||
The cursor will move with the image and be placed either right to the image or in the next line | ||
(see cursor positioning). | ||
|
||
If scrolling is off, the image gets painted from the top left of the current viewport | ||
and might be truncated if the image exceeds the viewport size. | ||
The cursor position does not change. | ||
|
||
You can customize this behavior with the constructor option `{sixelScrolling: false}` | ||
or with `DECSET 80` (off, binary: `\x1b [ ? 80 h`) and | ||
`DECRST 80` (on, binary: `\x1b [ ? 80 l`) during runtime. | ||
|
||
- **Cursor Positioning** | ||
If scrolling is set, the cursor will be placed at the beginning of the next row by default. | ||
You can change this behavior with the following terminal sequences: | ||
- `DECSET 8452` (binary: `\x1b [ ? 8452 h`) | ||
For images not overflowing to the right, the cursor will move to the next right cell of the last image cell. | ||
Images overflowing to the right, move the cursor to the next line. | ||
Same as the constructor option `{cursorRight: true}`. | ||
|
||
- `DECRST 8452` (binary: `\x1b [ ? 8452 l`) | ||
Always moves the cursor to the next line (default). Same as the constructor option `{cursorRight: false}`. | ||
|
||
- `DECRST 7730` (binary: `\x1b [ ? 7730 l`) | ||
Move the cursor on the next line to the image start offset instead of the beginning. | ||
This setting only applies if the cursor will wrap to the next line (thus never for scrolling off, | ||
for `DECSET 8452` only after overflowing to the right). Same as the constructor option `{cursorBelow: true}`. | ||
|
||
- `DECSET 7730` (binary: `\x1b [ ? 7730 h`) | ||
Keep the cursor on the next line at the beginning (default). Same as the constructor option `{cursorBelow: false}`. | ||
|
||
- **SIXEL Palette Handling** | ||
By default the addon limits the palette size to 256 registers (as demanded by the DEC specification). | ||
The limit can be increased to a maximum of 4096 registers (via `sixelPaletteLimit`). | ||
|
||
If `sixelPrivatePalette` is set (default), images are initialized with their own private palette derived from the default palette (`'VT340-COLOR'`). If `sixelPrivatePalette` is not set, the palette of the previous image will be used as initial palette. | ||
|
||
Note that the underlying SIXEL library currently applies colors immediately to pixels (*printer mode*), | ||
thus it is technically possible to use more colors in one image than the palette has color slots. | ||
This feature is called *high-color* in libsixel. | ||
|
||
In contrast older terminals were always bound to the palette due hardware limitations. | ||
This limitation is mimicked by xterm's shared palette mode, which will re-color previous images from palette changes | ||
treating all sixel images as indexed images. This true shared-palette *terminal mode* is currently not supported by | ||
xterm.js, as it always operates in *printer mode*. | ||
|
||
- **SIXEL Raster Attributes Handling** | ||
If raster attributes were found in the SIXEL data (level 2), the image will always be limited to the given height/width extend. We deviate here from the specification on purpose, as it allows several processing optimizations. For level 1 SIXEL data without any raster attributes the image can freely grow in width and height up to the last data byte, which has a much higher processing penalty. In general encoding libraries should not create level 1 data anymore and should not produce pixel information beyond the announced height/width extend. Both is discouraged by the >30 years old specification. | ||
|
||
Currently the SIXEL implementation of the addon does not take custom pixel sizes into account, a SIXEL pixel will map 1:1 to a screen pixel. | ||
|
||
### Storage and Drawing Settings | ||
|
||
The internal storage holds images up to `storageLimit` (in MB, calculated as 4-channel RBGA unpacked, default 100 MB). Once hit images get evicted by FIFO rules. Furthermore images on the alternate buffer will always be erased on buffer changes. | ||
|
||
The addon exposes two properties to interact with the storage limits at runtime: | ||
- `storageLimit` | ||
Change the value to your needs at runtime. This is especially useful, if you have multiple terminal | ||
instances running, that all add to one upper memory limit. | ||
- `storageUsage` | ||
Inspect the current memory usage of the image storage. | ||
|
||
By default the addon will show a placeholder pattern for evicted images that are still part | ||
of the terminal (e.g. in the scrollback). The pattern can be deactivated by toggling `showPlaceholder`. | ||
|
||
### Image Data Retrieval | ||
|
||
The addon provides the following API endpoints to retrieve raw image data as canvas: | ||
|
||
- `getImageAtBufferCell(x: number, y: number): HTMLCanvasElement | undefined` | ||
Returns the canvas containing the original image data (not resized) at the given buffer position. | ||
The buffer position is the 0-based absolute index (including scrollback at top). | ||
|
||
- `extractTileAtBufferCell(x: number, y: number): HTMLCanvasElement | undefined` | ||
Returns a canvas containing the actual single tile image data (maybe resized) at the given buffer position. | ||
The buffer position is the 0-based absolute index (including scrollback at top). | ||
Note that the canvas gets created and data copied over for every call, thus it is not suitable for performance critical actions. | ||
|
||
### Memory Usage | ||
|
||
The addon does most image processing in Javascript and therefore can occupy a rather big amount of memory. To get an idea where the memory gets eaten, lets look at the data flow and processing steps: | ||
- Incomming image data chunk at `term.write` (terminal) | ||
`term.write` might stock up incoming chunks. To circumvent this, you will need proper flow control (see xterm.js docs). Note that with image output it is more likely to run into this issue, as it can create lots of MBs in very short time. | ||
- Sequence Parser (terminal) | ||
The parser operates on a buffer containing up to 2^17 codepoints (~0.5 MB). | ||
- Sequence Handler - Chunk Processing (addon / mainthread) | ||
Image data chunks are copied over and sent to the decoder worker as transferables with `postMessage`. To avoid a data congestion at the message port, allowed SIXEL data is hard limited by `sixelSizeLimit` (default 25 MB). The transport chunks are pooled, the pool cache may hold up to ~6 MB during active data transmission. | ||
- Image Decoder (addon / worker) | ||
The decoder works chunkwise allocating memory as needed. The allowed image size gets restricted by `pixelLimit` (default 16M pixels), the decoder holds 2 pixel buffers at maximum during decoding (RGBA, ~128 MB for 16M pixels). | ||
After decoding the final pixel buffer is transferred back to the sequence handler. | ||
- Sequence Handler - Image Finalization (addon / mainthread) | ||
The pixel data gets written to a canvas of the same size (~64 MB for 16M pixels) and added to the storage. The pixel buffer is sent back to the worker to be used for the next image. | ||
- Image Storage (addon / mainthread) | ||
The image storage implements a FIFO cache, that will remove old images, if a new one arrives and `storageLimit` is hit (default 128 MB). The storage holds a canvas with the original image, and may additionally hold resized versions of images after a font rescaling. Both are accounted in `storageUsage` as a rough estimation of _pixels x 4 channels_. | ||
|
||
Following the steps above, a rough estimation of maximum memory usage by the addon can be calculated with these formulas (in bytes): | ||
```typescript | ||
// storage alone | ||
const storageBytes = storageUsage * storageLimit * 1024 * 1024; | ||
// decoding alone | ||
const decodingBytes = sixelSizeLimit + 2 * (pixelLimit * 4); | ||
|
||
// totals | ||
// inactive decoding | ||
const totalInactive = storageBytes; | ||
// active decoding | ||
const totalActive = storageBytes + decodingBytes; | ||
``` | ||
|
||
Note that browsers have offloading tricks for rarely touched memory segments, esp. `storageBytes` might not directly translate into real memory usage. Usage peaks will happen during active decoding of multiple big images due to the need of 2 full pixel buffers at the same time, which cannot be offloaded. Thus you may want to keep an eye on `pixelLimit` under limited memory conditions. | ||
Further note that the formulas above do not respect the Javascript object's overhead. Compared to the raw buffer needs the book keeping by these objects is rather small (<<5%). | ||
|
||
_Why should I care about memory usage at all?_ | ||
Well you don't have to, and it probably will just work fine with the addon defaults. But for bigger integrations, where much more data is held in the Javascript context (like multiple terminals on one page), it is likely to hit the engine's memory limit sooner or later under decoding and/or storage pressure. | ||
|
||
_How can I adjust the memory usage?_ | ||
- `pixelLimit` | ||
A constructor settings, thus you would have to anticipate, whether (multiple) terminals in your page gonna do lots of concurrent decoding. Since this is normally not the case and the memory usage is only temporarily peaking, a rather high value should work even with multiple terminals in one page. | ||
- `storageLimit` | ||
A constructor and a runtime setting. In conjunction with `storageUsage` you can do runtime checks and adjust the limit to your needs. If you have to lower the limit below the current usage, images will be removed and may turn into a placeholder in the terminal's scrollback (if `showPlaceholder` is set). When adjusting keep in mind to leave enough room for memory peaking for decoding. | ||
- `sixelSizeLimit` | ||
A constructor setting. This has only a small direct impact on peaking memory during decoding. It still will avoid processing of overly big or broken sequences at an earlier phase, thus may stop the decoder from entering its memory intensive task for potentially invalid data. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const sixelEncode = require('../node_modules/sixel/lib/SixelEncoder').image2sixel; | ||
const toRGBA8888 = require('../node_modules/sixel/lib/Colors').toRGBA8888; | ||
|
||
function createRect(size, color) { | ||
const pixels = new Uint32Array(size * size); | ||
pixels.fill(toRGBA8888(...color)); | ||
return sixelEncode(new Uint8ClampedArray(pixels.buffer), size, size); | ||
} | ||
|
||
function createRectMinusOne(size, color) { | ||
const pixels = new Uint32Array(size * size); | ||
if (size - 1) { | ||
const sub = new Uint32Array(size - 1); | ||
sub.fill(toRGBA8888(...color)); | ||
const last = size * (size - 1); | ||
for (let y = 0; y < last; y += size) { | ||
pixels.set(sub, y); | ||
} | ||
} | ||
return sixelEncode(new Uint8ClampedArray(pixels.buffer), size, size); | ||
} | ||
|
||
async function main() { | ||
// clear + cursor and sixelScrolling off | ||
process.stdout.write('\x1b[2J\x1b[?25;80l'); | ||
|
||
for (let i = 1; i < 300; ++i) { | ||
await new Promise(res => setTimeout(() => { | ||
process.stdout.write(createRect(i, [0, 255, 0])); | ||
res(); | ||
}, 5)); | ||
} | ||
for (let i = 299; i >= 1; --i) { | ||
await new Promise(res => setTimeout(() => { | ||
process.stdout.write(createRectMinusOne(i, [0, 255, 0])); | ||
res(); | ||
}, 5)); | ||
} | ||
|
||
// re-enable cursor and sixel scrolling | ||
process.stdout.write('\x1b[2J\x1b[?25;80h'); | ||
} | ||
|
||
main(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all these compiler options? This might be convenient but it doesn't end up using the TS project tsconfig.json which might lead to future weirdness. perhaps waiting until eslint supports project references is a better way typescript-eslint/typescript-eslint#2094?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I basically did a c&p & merge from tsconfigs to make sure, no new rules slip into. Not sure if those rules are needed at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently in master eslint will go through all addons with their project references separately, which takes alot of time and memory. With the image addon added, this does not work anymore, eslint runs into OOM. Thus waiting is no option (unless we disable eslint for addons)?
Now the idea of that additional tsconfig file is to give eslint a single project entry for all addons at once. I had to do this, because of your linked issue. With this eslint works again.
The tsconfig file is simply a merger of the single ones at individual addon level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint hits oom 🤯
It's probably fine like this if there's performance issues, not sure if eslint would need anything specific from the tsconfig.json to do its thing anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure either. Tbh I dont like the fact, that the linter operates on a fake project, that never gets used/built by TS, but it was the only way I found avoid the OOM. The linting though works correctly across lib borders (tested manually by doing forth and back changes at various places).
If you have no other ideas how to circumvent the OOM by some simpler settings, I'd leave it that way for now.