I've been experiencing some unusual behavior with web workers in a three.js application. Initially, everything looks fine when loading a new page.
However, after about 20 page reloads, and only when web workers are running, this strange phenomenon occurs:
Suddenly, my cube appears zoomed in the top right corner! It seems to happen after multiple reloads for some reason.
Oddly enough, if I resize my screen to be smaller, the cube snaps back to the center. I checked and found that the ratio of screen height/width is not consistent when this snapback happens.
Furthermore, continuous reloading leads to the cube eventually disappearing entirely, resulting in a blank screen. However, if I reload the page in a new window, everything goes back to normal.
Initially, I suspected the issue might be related to improper termination of web workers. I tried setting up a beforeunload
event handler to terminate all workers, but it didn't solve the problem. So, I'm unsure of what exactly is causing this strange behavior. Can anyone help?
For reference, I'm using Chrome 24, and the issue doesn't seem to occur on Firefox 18.