Can you be a bit more precise about this. Is it iOS vs Android? Or is it depending on browser?
Can you make a list of the tested devices working fine and those where you experience the bug?
Given this information, I would say the same as @aWeirdo. It would eventually need to be worked at device level. Also the idea from @nogalo of wrapping everything in an iFrame could be worth exploring and could do the trick. Again, hard to give you just the 'automagical solution with just the information above.
Edit: And I was just thinking with a delay: Did you use idealWidth and/or idealHeight? Obviously, you would want to switch these when changing orientation.