Howdy,
before I start: I am pretty new to this kind of business - I'm trying to build my first game using the arche ECS framework which seemed to be one of the more mature ones (from what I could tell).
Ok, sofar I have 7 different components in my world. Here are the stats:
World -- Components: 7, Nodes: 10, Filters: 0, Memory: 42.0 kB, Locked: false
Components: Position, Velocity, Player, Collectible, Renderable, Tilish, Solid
Entities -- Used: 300, Recycled: 0, Total: 300, Capacity: 384
Node -- Components: 0, Entities: 0, Capacity: 1, Memory: 0.0 kB, Per entity: 0 B
Components:
Node -- Components: 4, Entities: 85, Capacity: 128, Memory: 6.0 kB, Per entity: 40 B
Components: Position, Renderable, Tilish, Solid
Node -- Components: 2, Entities: 212, Capacity: 256, Memory: 10.0 kB, Per entity: 32 B
Components: Position, Tilish
Node -- Components: 4, Entities: 1, Capacity: 128, Memory: 11.0 kB, Per entity: 80 B
Components: Position, Velocity, Player, Renderable
Node -- Components: 3, Entities: 2, Capacity: 128, Memory: 6.0 kB, Per entity: 40 B
Components: Position, Collectible, Renderable
However, when I start it and move the player around a little bit, after a while the game crashes:
panic: run out of the maximum of 256 bits
goroutine 48 [running]:
github.com/mlange-42/arche/ecs.(*bitPool).getNew(0xaa0e28?)
/home/scip/go/pkg/mod/github.com/mlange-42/[email protected]/ecs/pool.go:120 +0x94
github.com/mlange-42/arche/ecs.(*bitPool).Get(0xb673a0?)
/home/scip/go/pkg/mod/github.com/mlange-42/[email protected]/ecs/pool.go:109 +0x1c
github.com/mlange-42/arche/ecs.(*lockMask).Lock(0xc0000a4638)
/home/scip/go/pkg/mod/github.com/mlange-42/[email protected]/ecs/util.go:111 +0x25
github.com/mlange-42/arche/ecs.(*World).lock(...)
/home/scip/go/pkg/mod/github.com/mlange-42/[email protected]/ecs/world_internal.go:865
github.com/mlange-42/arche/ecs.(*World).Query(0xc0000a4480, {0x870858?, 0xc0107d6160})
/home/scip/go/pkg/mod/github.com/mlange-42/[email protected]/ecs/world.go:368 +0x67
openquell/game.(*Level).Update(0xc000492000)
/home/scip/dev/openquell/game/levels.go:67 +0x125
openquell/game.(*LevelScene).Update(0xc0003abbe8?)
/home/scip/dev/openquell/game/levelscene.go:43 +0x27
openquell/game.(*Game).Update(0xc0003abc70?)
/home/scip/dev/openquell/game/game.go:40 +0x59
github.com/hajimehoshi/ebiten/v2.(*gameForUI).Update(0xc0004ca690)
/home/scip/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/gameforui.go:142 +0x23
github.com/hajimehoshi/ebiten/v2/internal/ui.(*context).updateFrameImpl(0xc0001cf580, {0x8773c0, 0xc00011bb00}, 0x1, 0x4084000000000000, 0x407e000000000000, 0x7f5d6065ef18?, 0xb36f60, 0x0?, 0xc010adb040)
/home/scip/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/ui/context.go:145 +0x3ea
github.com/hajimehoshi/ebiten/v2/internal/ui.(*context).updateFrame(0xc000193220?, {0x8773c0, 0xc00011bb00}, 0xc1690b221d5d1bd3?, 0x11bad77a7?, 0xb365e0?, 0xc000112eb0?, 0xc000112eb0?)
/home/scip/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/ui/context.go:75 +0x89
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).updateGame(0xb36f60)
/home/scip/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/ui/ui_glfw.go:1231 +0x1da
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).loopGame(0xb36f60)
/home/scip/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/ui/ui_glfw.go:1199 +0xac
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).Run.func2()
/home/scip/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/ui/run_glfw_notsinglethread.go:60 +0x37
golang.org/x/sync/errgroup.(*Group).Go.func1()
/home/scip/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
/home/scip/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:72 +0x96
I'm not sure how to create a small example to reproduce the problem. Basically I use the generic aproach to build the world. I could show you the source if that helps?
The crash happens here:
https://repo.daemon.de/scip/openquell/src/branch/master/game/levels.go#L67
The filters (I call them selectors) are being intantiated once per level in NewLevel()
here:
https://repo.daemon.de/scip/openquell/src/branch/master/game/levels.go#L32
Entity + component creation happens in NewGrid()
here (based on a map):
https://repo.daemon.de/scip/openquell/src/branch/master/game/grid.go#L27
The ecs.World
object is a member of the Game
struct, so it's not global but always the same.
The crash first occurred after I added the Collectibles
component, I did not have the problem as long as I only had solids and the player components.
What's also interesting: if I only use 1 entity using the Collectibles component, then the crash occurs much later (but it happens anyway). It'd probably happen without any collectibles anyway but I didn't fiddle long enough around in the game. So it seems to me, these components add up somewhere with every loop the game goes in. But I have no clue where to look at, to be honest.
Would be great if you'd have an idea (or it might also be a bug, dunno).
Thanks in advance,
Tom