rprichard/x11-canvas-screencast

Error when packing

perpetual-hydrofoil opened this issue · 5 comments

jamieson@box: ~/x11-canvas-screencast/ # ./pack_animation.py example.js
example packing, num rects: 442 num frames: 320

Traceback (most recent call last):
File "./pack_animation.py", line 302, in
generate_animation(sys.argv[1])
File "./pack_animation.py", line 255, in generate_animation
dy, dx = allocator.allocate(w, h)
File "./pack_animation.py", line 109, in allocate
raise RuntimeError()
RuntimeError

I'm not all that familiar with the Python code that's failing. The image processing parts all came from Sublime's anim_encoder project.

It looks like it's trying to allocate space in the output bitmap and running out. You could try increasing MAX_PACKED_HEIGHT to something larger than 10000. I guess it ought to resize the bitmap when that happens. I wonder what the run-time of find_matching_rect is, though. If the output bitmap grows too much, perhaps the script will be too slow.

I also wonder what would happen if the images didn't all have the same size, because the output bitmap has the same width as the first image. The images should all have the same size, though, as long as x11-canvas-screencast generated them.

I see... I haven't looked at the code yet, but is there any way to get a better traceback or debug mode? (These were generated by x11-canvas-screencast.)

... is there any way to get a better traceback or debug mode?

Not that I know of. The code is fairly short, though, so if you know Python, it shouldn't be too hard to debug.

wbond commented

Just a note, the run time does increase because currently anim_encoder searches the existing image data whenever adding a rect to the packed result. As the buffer gets larger, the number of locations that need to be searched increases also.

According to the source comments, reusing the image data resulted in up to a 20% savings in some of the Sublime Text screencasts originally recorded. That savings may not be worth it once it starts taking 20 minutes to pack the image data.