Skip to content
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

Panic when drawing off the edge of an offscreen image #8

Open
kalexmills opened this issue Apr 30, 2023 · 3 comments
Open

Panic when drawing off the edge of an offscreen image #8

kalexmills opened this issue Apr 30, 2023 · 3 comments

Comments

@kalexmills
Copy link

panic: runtime error: index out of range [28] with length 28

goroutine 10 [running]:
golang.org/x/image/vector.(*Rasterizer).rasterizeDstAlphaSrcOpaqueOpSrc(0x1400016cab0, 0x140010f9200, {{0x14000f715f8?, 0x100a74078?}, {0x14000f715f8?, 0x100a74018?}})
        /Users/kalexmills/go/pkg/mod/golang.org/x/[email protected]/vector/vector.go:384 +0x1b4
golang.org/x/image/vector.(*Rasterizer).Draw(0x1400016cab0, {0x1012f21b8?, 0x140010f9200}, {{0x24?, 0x0?}, {0x0?, 0x0?}}, {0x1012f1820?, 0x14000192410?}, {0x0?, ...})
        /Users/kalexmills/go/pkg/mod/golang.org/x/[email protected]/vector/vector.go:281 +0xf4
github.com/tinne26/etxt/emask.(*DefaultRasterizer).Rasterize(0x1400016cab0, {0x1400012d500, 0x24, 0x40}, {0xf71798?, 0x140?})
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/emask/impl_default.go:87 +0xf0
github.com/tinne26/etxt/emask.Rasterize({0x1400012d500?, 0x1008233d4?, 0x30000000028?}, {0x1012f0b30?, 0x1400016cab0?}, {0x36c?, 0x234?})
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/emask/rasterizer.go:105 +0x84
github.com/tinne26/etxt.(*Renderer).LoadGlyphMask(0x140003b4700, 0x28, {0x1?, 0x1?})
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/renderer_draw.go:73 +0x98
github.com/tinne26/etxt.(*Renderer).DrawFract.func1({0x18?, 0x0?}, 0x12a2980?, 0x1?)
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/renderer_draw.go:45 +0x58
github.com/tinne26/etxt.(*Renderer).Traverse.func1({0x28e013d8?, 0x1?})
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/renderer_traverse.go:112 +0x2c
github.com/tinne26/etxt.(*Renderer).traverseGlyphLTR(0x140003b4700, {0x12a2980?, 0x1?}, {0x1?, 0x0?, 0x0?}, 0x140007da198)
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/renderer_traverse.go:246 +0xcc
github.com/tinne26/etxt.(*Renderer).Traverse(0x140003b4700, {0x140019940e4, 0xa}, {0x8c0, 0x140?}, 0x140016d7020)
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/renderer_traverse.go:111 +0x3f8
github.com/tinne26/etxt.(*Renderer).DrawFract(0x140003b4700, {0x140019940e4, 0xa}, 0x1?, 0x0?)
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/renderer_draw.go:42 +0xa4
github.com/tinne26/etxt.(*Renderer).Draw(...)
        /Users/kalexmills/go/pkg/mod/github.com/tinne26/[email protected]/renderer_draw.go:25
github.com/Frabjous-Studios/ebitengine-game-template/internal.(*MainScene).randCheck(0x1400011a000)
        /Users/kalexmills/repos/personal/ldjam-53/internal/main_scene.go:1276 +0x3ec
github.com/Frabjous-Studios/ebitengine-game-template/internal.(*MainScene).putCounter(0x1400011a000, {0x140007fe090?, 0x1, 0x1?})
        /Users/kalexmills/repos/personal/ldjam-53/internal/main_scene.go:1027 +0xb8
github.com/Frabjous-Studios/ebitengine-game-template/internal.(*MainScene).Command(0x1400011a000, {0x140001b63d8, 0x12})
        /Users/kalexmills/repos/personal/ldjam-53/internal/main_scene.go:847 +0x2e4
github.com/DrJosh9000/yarn.(*VirtualMachine).execRunCommand(0x1400088c980?, {0x140002b0350?, 0x1?, 0x14000714d20?})
        /Users/kalexmills/go/pkg/mod/github.com/!dr!josh9000/[email protected]/vm.go:326 +0x234
github.com/DrJosh9000/yarn.(*VirtualMachine).execute(0x0?, 0x0?)
        /Users/kalexmills/go/pkg/mod/github.com/!dr!josh9000/[email protected]/vm.go:228 +0x9c
github.com/DrJosh9000/yarn.(*VirtualMachine).Run(0x1400088c980, {0x100c42151, 0x12})
        /Users/kalexmills/go/pkg/mod/github.com/!dr!josh9000/[email protected]/vm.go:186 +0x3bc
github.com/Frabjous-Studios/ebitengine-game-template/internal.(*DialogueRunner).DoNode(0x1400031bf10?, {0x100c42151?, 0x0?})
        /Users/kalexmills/repos/personal/ldjam-53/internal/dialogue_runner.go:86 +0xa0
github.com/Frabjous-Studios/ebitengine-game-template/internal.(*MainScene).startRunner(0x1400011a000)
        /Users/kalexmills/repos/personal/ldjam-53/internal/main_scene.go:746 +0x58
created by github.com/Frabjous-Studios/ebitengine-game-template/internal.(*MainScene).Update
        /Users/kalexmills/repos/personal/ldjam-53/internal/main_scene.go:262 +0x17c
exit status 2

Seen at commit24101a8

@tinne26
Copy link
Owner

tinne26 commented May 1, 2023

It very much looks like the TODO in Golang's code at fault: https://cs.opensource.google/go/x/image/+/refs/tags/v0.7.0:vector/vector.go;l=268. We probably want to get the actual values of bounds and points and rects to debug. It should be patchable from etxt's end, but that's not very ideal; a more minimal example reported to Golang directly may be the way to go here. I'll look into it when I can, but it may take a few days.

I'm particularly interested in a more minimal example because since this doesn't seem to be etxt's fault, it may also affect ebiten/text. A temporary workaround may involve trying to render with https://pkg.go.dev/github.com/tinne26/[email protected]/emask#EdgeMarkerRasterizer instead (though that's much less tested and slower and it doesn't give the best guarantees either).

@tinne26
Copy link
Owner

tinne26 commented May 1, 2023

I tried to compile your project to reproduce the issue and try the quickfix with EdgeMarkRasterizer, but failed to do so. I installed ysc and compiled the yarn files, but then I got other errors for missing files:

2023/05/01 09:29:20 fonts available: Munro,Munro Narrow,Munro Small,Roustel Regular,Thesignature,Honey Script Light,Honey Script SemiBold
2023/05/01 09:29:20 error loading animation: scan_shreder.json: open gamedata\img\scan_shreder.png: file does not exist
2023/05/01 09:29:20 failed to load image: gamedata/img/head_psychoClown: open gamedata/img/head_psychoClown: file does not exist

[...]

Edit: I guess it's due to you testing on linux and me using windows at the moment, the paths may not be properly handled.
Edit 2: yeah, with linux it compiles.
Edit 3: yeah, actually a bit offtopic. But https://github.com/kalexmills/asebiten/blob/ed6ad7918bccfc3d0a8bf7d37715aaa939c8ff5c/aseprite.go#L157 this usage of filepath is incorrect. Since you used fs.FS you should use path instead. That causes the animation error. The other is due to head_psychoClown missing the .png extension in your files.

@kalexmills
Copy link
Author

kalexmills commented May 1, 2023

this usage of filepath is incorrect

Jesus; I literally did the same thing a few weeks ago and I think you pointed it out in the Ebitengine Discord. After this Game jam I'm making a resources library and never writing this code again. ;)

EDIT:

I installed ysc and compiled the yarn files, but then I got other errors for missing files:

You're trying too hard. Thanks! I really appreciate it. Feel free to kick it back to me next time, though. There ought to be precompiled yarn files in the repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants