So if I'm understanding this code correctly, you're always creating a preview image that is the size of the space available on screen.  And parts outside of the preview remain default transparent black...   That explains my comments above. I was assuming you were creating a preview image as small as possible.  I haven't run this code yet, but I would guess that a preview image like that would cause problems for the border drawing feature of the webgl shader.