This is a build-time configuration setting currently in js/config.js.  I think you need to respect that setting until you switch over making this file built-time configurable. So this should be initialized to CONFIG_MAX_SHAPSHOT_PIXEL_SIZE, I think.  And you should change from maxByte to maxPixels or similar.