fix(composite): recover from sixel encoder panics, clean up debug logging
The go-sixel library panics on certain image dimensions during Resize(). Added panic recovery in drawImage() that falls back to alt text display. Cleaned up all debug logging from the investigation.
This commit is contained in:
@@ -252,6 +252,19 @@ func (cc *compositeContent) drawImage(ctx *ui.Context, idx, row, width, height i
|
|||||||
|
|
||||||
vx := ctx.Window().Vx
|
vx := ctx.Window().Vx
|
||||||
graphic, ok := cc.graphics[idx]
|
graphic, ok := cc.graphics[idx]
|
||||||
|
// Recover from panics in vaxis image encoding (e.g. sixel encoder bugs)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
log.Errorf("composite: panic rendering image %d: %v", idx, r)
|
||||||
|
alt := "[image: render error]"
|
||||||
|
if idx < len(cc.images) && cc.images[idx].Alt != "" {
|
||||||
|
alt = fmt.Sprintf("[%s]", cc.images[idx].Alt)
|
||||||
|
}
|
||||||
|
if row >= 0 && row < ctx.Height() {
|
||||||
|
ctx.Printf(0, row, style, "%s", alt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
if !ok {
|
if !ok {
|
||||||
var err error
|
var err error
|
||||||
graphic, err = vx.NewImage(img)
|
graphic, err = vx.NewImage(img)
|
||||||
|
|||||||
Reference in New Issue
Block a user