Closed hanchon closed 6 months ago
Update: Creating the minimal example was simpler than expected, you can run it locally:
_ = filterThatFails.Query(&w)
always panic for me, without that line it works fine.
I used the v0.11.0
version of the lib for this example
package main
import (
"github.com/mlange-42/arche/ecs"
"github.com/mlange-42/arche/generic"
)
type Component1 struct {
}
type Component2 struct {
}
type Component3 struct {
}
type Component4 struct {
}
type Component5 struct {
}
type Component6 struct {
}
type Component7 struct {
}
type Component8 struct {
}
type Component9 struct {
}
type Component10 struct {
}
type Component11 struct {
}
type Component12 struct {
}
type Component13 struct {
}
type Component14 struct {
}
type Component15 struct {
}
type Component16 struct {
}
type Component17 struct {
}
type Component18 struct {
}
func main() {
w := ecs.NewWorld()
builderFirst10 := generic.NewMap10[
Component1,
Component2,
Component3,
Component4,
Component5,
Component6,
Component7,
Component8,
Component9,
Component10,
](&w)
_ = builderFirst10.New()
builderNext6 := generic.NewMap6[
Component12,
Component13,
Component14,
Component15,
Component16,
Component17,
](&w)
_ = builderNext6.New()
filter := generic.NewFilter1[Component1]()
res := filter.Query(&w)
for res.Next() {
continue
}
builderWithError := generic.NewMap1[Component18](&w)
_ = builderWithError.New()
filterThatFails := generic.NewFilter1[Component18]()
_ = filterThatFails.Query(&w)
}
go get github.com/mlange-42/arche@2ae05f972ba46b3668cdf40b7d1d864d8d775ca5
go run main.go
Run with no issues
go get github.com/mlange-42/arche@55baf5abc1995fd48317cae77d4f5f3a3ac4e78d
go run main.go
Panics
The pr that broke it is #327 , the initial value is working fine (16
) but the size is not increasing when needed.
Hi @hanchon, many thanks for reporting! I will look into it.
Solved. The problem was a missing check whether an archetype (more exactly, an archetype node) is active, before extending the layouts.
"Inactive" archetypes nodes are those that do not actually contain entities (or even archetypes), as they are just traversed when traversing the archetype graph. See Architecture # Archetype graph in the user guide for more information on the archetype graph, in case you are interested.
Will merge and make a new release tomorrow or later today.
Many thanks again for spotting this, and for the very detailed bug report! Cheers!
Awesome! Tomorrow I'll build locally the pr #416 to try it out. Thank you for the quick fix!
I just tried #416 -> commit:4685db2374b629f22a9dfc32f4e14284cd40a060
, and it's working great!
Thanks for solving the problem, i'll keep using my local build of arche
until there is a new release.
@hanchon FYI: the fix was just released with v0.12.0
Hi, I was playing with the lib and Ebitengine to create a simple word game. Everything was working as expected with no issues until I tried to add the 17th component. I was not able to have a minimal reproducible example, but I'll try to make one next week. I am opening the issue to start talking about the problem.
If I have 16 components everything is working great, no issues there. As soon as I add a new component (I created a simple boolean component in case the error was related to the pointer to the sprite):
Component:
Entity:
Scene loader:
After adding the line
entity.NewBackground(world)
, my draw function started to panic. Without that line, everything works as expected.Panic error:
Draw function:
I went deep into the panic error and I found that the issue in related to the
compile
function for the filter. Used in the lineres := c.filter.Query(c.world)
. The problem is that the*ecs.archetype
isnil
but I can not figure it out why. The file isarche/ecs/archetype.go
and herea
isnil
, soa.layouts
is the reason of the panic.If I create new entities using any other component the program works without any issue, but as soon as I try to use the
BgSprite
component I get the panic.Sorry for the wall of text, maybe you can find my issue with this information, but I'll try to make a smaller example to replicate my issue so it's easier to debug.
Thanks
PD: I am using the current
main
(1f3a73586dbf70c153a535bac5666fa72f1b02f1
) but I also tried thev0.11.0
tag and I found the same issue. PD2: I tried also to recreate the filter each time inside the draw function, but I got the same panic. PD3: If i keep adding more components different filters calls start to panic, I think that is related to the pages that are changing in the filearche/ecs/utils.go
Debugger screenshots included: