Fatal error when use many Text graphic in Tilemap.
See original GitHub issueSteps to Reproduce
DL my repo ↓.
npm install
npm run start
Tap/click about 40 times in the game screen.
my code
import { Color, Engine, Scene, Text, TileMap, Vector } from "excalibur";
import { PointerEvent } from "excalibur/build/dist/Input/PointerEvent";
export class GameScene extends Scene {
private tilemap!: TileMap;
onInitialize(engine: Engine): void {
this.tilemap = new TileMap({
pos: Vector.Zero,
rows: 24,
columns: 16,
tileWidth: 32,
tileHeight: 32,
});
engine.add(this.tilemap);
this.tilemap.tiles.forEach((tile) => {
tile.data.set("id", 0);
});
engine.input.pointers.primary.on("down", (event: PointerEvent): void => {
this.tilemap.tiles.forEach((tile) => {
const id = tile.data.get("id")!;
tile.data.set("id", id + 1);
});
this.updateTilemap();
});
}
updateTilemap(): void {
this.tilemap.tiles.forEach((tile) => {
const id = tile.data.get("id")!;
const text = new Text({
text: `${id}`,
color: Color.White,
});
tile.clearGraphics();
tile.addGraphic(text);
});
}
}
Expected Result
A fatal error doesn’t occur.
Actual Result
A fatal error occurs.
The logs are as follows.
Powered by Excalibur.js (v0.27.0)
127.0.0.1꞉1234/index.b71e74eb.js:23242
/| ________________
O|===|* >________________>
\|
127.0.0.1꞉1234/index.b71e74eb.js:23244
Visit http://excaliburjs.com for more information
127.0.0.1꞉1234/index.b71e74eb.js:23246
[Warn] : Excalibur was unable to unlock the audio context, audio probably will not play in this browser.
node_modules/excalibur/build/esm/webpack:/Collision/Side.ts:3
[67465:259:0718/164454.220576:ERROR:io_surface.cc(301)] Failed to allocate IOSurface of size 75x63.
[67465:259:0718/164454.220605:ERROR:gpu_memory_buffer_factory_io_surface.cc(173)] Failed to allocate IOSurface.
[67465:259:0718/164454.220625:ERROR:io_surface.cc(301)] Failed to allocate IOSurface of size 75x63.
[67465:259:0718/164454.220635:ERROR:gpu_memory_buffer_factory_io_surface.cc(173)] Failed to allocate IOSurface.
[67465:259:0718/164454.220642:ERROR:shared_image_backing_factory_gl_image.cc(355)] CreateSharedImage: Failed to create bindable image
[67465:259:0718/164454.220649:ERROR:shared_image_factory.cc(770)] CreateSharedImage: could not create backing.
[67465:259:0718/164454.220654:ERROR:shared_image_stub.cc(246)] SharedImageStub: Unable to create shared image
[67465:259:0718/164457.177493:ERROR:shared_image_manager.cc(277)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox.
[67465:259:0718/164457.177515:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox.
[67465:259:0718/164457.177761:ERROR:shared_image_manager.cc(277)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox.
[67465:259:0718/164457.177782:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox.
[67465:259:0718/164457.177965:ERROR:shared_image_manager.cc(277)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox.
[67465:259:0718/164457.177989:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox.
[Fatal] : Error: Uniform uniformMatrix4fv:u_matrix doesn't exist or is not used in the shader source code, unused uniforms are optimized away by most browsers
at Shader.setUniform (/Users/tenpamk2/repo/excalibur-examples/examples/dungeon-generator/node_modules/excalibur/build/esm/webpack:/Graphics/Context/circle-renderer/circle-renderer.ts:57:9)
at Shader.setUniformMatrix (/Users/tenpamk2/repo/excalibur-examples/examples/dungeon-generator/node_modules/excalibur/build/esm/webpack:/Graphics/Context/circle-renderer/circle-renderer.ts:52:26)
at ImageRenderer.flush (/Users/tenpamk2/repo/excalibur-examples/examples/dungeon-generator/node_modules/excalibur/build/esm/webpack:/Graphics/Context/ExcaliburGraphicsContext2DCanvas.ts:282:4)
at ExcaliburGraphicsContextWebGL.flush (:8211:76)
at Engine._draw (:23738:34)
at Engine._mainloop (:23846:18)
at StandardClock.update (:22956:26)
at mainloop (http://127.0.0.1:1234/index.b71e74eb.js:22986:26) {stack: 'Error: Uniform uniformMatrix4fv:u_matrix does…://127.0.0.1:1234/index.b71e74eb.js:22986:26)', message: 'Uniform uniformMatrix4fv:u_matrix doesn't ex…uniforms are optimized away by most browsers'}
Environment
- browsers and versions: Chrome 103.0.5060.114(Official Build) (x86_64)
- operating system: Mac OS Monterey 12.4
- Excalibur versions: 0.27.0
- Memory: 16GB
- GPU: Intel UHD Graphics 630 1536MB
Current Workaround
nothing.
my guess
I always clear the graphics before using new graphic in my code as follows.
tile.clearGraphics();
tile.addGraphic(text);
However, on my machine, there seems to be some sort of cache left over that is consuming memory or something.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
LibGDX - Text over texture in tile / tilemaps - Stack Overflow
New Answer: Since your new BitmapFont font is static, itll be loaded before Gdx is initialized. Thats why it wont work.
Read more >Fatal Error Stack Frame? : r/gamemaker - Reddit
I was trying to implement a slope collision system to my tileset collisions and I received this error: FATAL ERROR in action number...
Read more >Tilemap editor feature · Issue #977 - GitHub
Each pixel in the tilemap image will be a 32-bit value with some bits to reference the tile in the tileset and other...
Read more >Fatal error in Unity CIL Linker 2017.2.0f3
Same here but updating Unity IAP and reimporting it several times didn't solve my problem. Platform : Android Unity version : 2017.2.0f3. NDK ......
Read more >Learn how to use tilemap by making a platform game with it!
Back to Construct 2, add a New object > General > Tilemap (double click on Layout or in Object tab, right click >...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@eonarheim , Thanks for fixing.
I tried to execute same code (not use workaround) on 0.28.0-alpha.529, but a fatal error still occured 😓 Is it your expected result?
Which one is correct?
0.28.0-alpha.529
works OK but has performance issue.0.28.0-alpha.529
works NG because of performance issue but workaround works OK.Your workaround works OK. Thank you very much❗
@eonarheim I’m glad (sad?) you can reproduce it. Thanks. Sorry, I don’t know how difficult it is, but option 1 seems like a good choice.