What happens to an HTML5 web worker thread when the tab is closed while it's running?

前端 未结 2 854
失恋的感觉
失恋的感觉 2020-12-05 15:04

I\'m wondering what happens when a user closes the tab which spawned the worker thread, while the thread is still working. Does it halt everything? If so, is there a way to

2条回答
  •  情书的邮戳
    2020-12-05 15:26

    Take a look here

    http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#workerglobalscope

    I think it is confirming that once the browser goes away, any workers must stop.

    Whenever a Document object is discarded, it must be removed from the list of the worker's Documents of each worker whose list contains that Document.

    In the case where you have one window using web workers, and you close that window (or tab), the worker goes away.

    If you have a case where you have a window, that opens other windows or tabs, the workers can continue. But if you close everything, they all go away.

提交回复
热议问题