resolve issue #1242: reverse order of init and doMath so that viewport is initialized when determining width