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

image/gif: generated image cannot be opened in xv and crashes OmniWeb 3.x web browser #33748

Open
tenox7 opened this issue Aug 21, 2019 · 7 comments

Comments

@tenox7
Copy link

commented Aug 21, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.5 linux/amd64

Does this issue reproduce with the latest release?

yes, any release

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/tenox/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/google/home/tenox/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/google-golang"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build197159774=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Create a simple gif image:

package main

import (
	"image"
	"image/color"
	"image/gif"
	"os"
	"fmt"
)

func main() {
	g, _ := os.Create("go.gif")
	defer g.Close()
	p := []color.Color{color.White, color.Black}
	r := image.Rect(0,0,100,100)
	i := image.NewPaletted(r, p)
	for x:=20; x<40; x++ {
		for y:=20; y<40; y++ {
			fmt.Printf("%d %d", x, y)
			i.SetColorIndex(x,y, 1)
		}
	}
	gif.Encode(g, i, nil)
}

What did you expect to see?

Expected to open in older image viewers, editors and browsers.

What did you see instead?

A number of old browsers, image viewers and editors report generated gif image as corrupted or display it mangled. For example xv image viewer, https://en.wikipedia.org/wiki/Xv_(software) says the file is turncated. OmniWeb browser (v2.x and v3.x) crashes. Most graphical software on SGI IRIX reports it corrupted.

@odeke-em odeke-em changed the title image/gif corrupted in older viewers image/gif: generated image cannot render and is reported as corrupted in older viewers Aug 21, 2019

@odeke-em

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

Thank you for reporting this issue @tenox7!

Kindly pinging some folks who might be able to help @nigeltao @horgh.

@odeke-em odeke-em added this to the Go1.14 milestone Aug 21, 2019

@smasher164

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

Xv states that the file is truncated.
xverr

I assume you mean <= Omniweb 5, since Omniweb 6 renders the gif properly.
correctomniweb6

@tenox7

This comment has been minimized.

Copy link
Author

commented Aug 21, 2019

Yes OmniWeb 2.x and 3.x. I have updated the description, thank you. Actually in a fact reloading the gif image in OmniWeb 3.0 causes the browser to crash.

image

@tenox7

This comment has been minimized.

Copy link
Author

commented Aug 21, 2019

XV debug mode says this:

LoadGIF: imagesep (got=0)    at start: offset=0x14
xv: LoadGIF() - picture is 100x100, 1 bits, non-interlaced
  at end:   dataptr=0xc9

LoadGIF: trailerxv: Desired colormap
(  0  ff,ff,ff 9978)
(  1  00,00,00 22)


xv: result of sorting colormap
(  0  ff,ff,ff)     (  1  00,00,00)     

@tenox7 tenox7 changed the title image/gif: generated image cannot render and is reported as corrupted in older viewers image/gif: generated image cannot be opened in xv and crashes OmniWeb 3.x web browser Aug 21, 2019

@nigeltao

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2019

It's possibly the same issue as #13746 (comment) with the eog ("Eye of GNOME") image viewer.

It's hard to say definitively, though. It's fair enough to say that Go's GIF encoder is writing something that old image viewers can't read, but it's hard to do something about that (in the Go code) without knowing what it is specifically those old image viewers don't like. And figuring out what they don't like probably means spelunking in xv or OmniWeb code, not in Go code.

Or, as I said in issue #13746, if it's:

For example, the "GIF image loader cannot understand this image" error message comes from https://github.com/GNOME/gdk-pixbuf/blob/master/gdk-pixbuf/io-gif.c#L634 in the lzw_read_byte function, and the comment immediately above that says: "FIXME - we should handle this case".

then it's really up to EoG to fix their bug. Which they might already have done (in GNOME/gdk-pixbuf@b88f1ce, not sure if it's rolled out to stable distro's yet).

@tenox7

This comment has been minimized.

Copy link
Author

commented Aug 22, 2019

I also think that this may be to do with LZW compression. Would it be possible to add an option to disable LZW compression when creating GIFs?

@nigeltao

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2019

I don't think you can have a GIF image without LZW compression.

This is in terms of the GIF file format, not any one specific encoder or decoder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.