Avoid crash in Chrome, issue 41487612 (#16893)
Fixes Chrome issue 41487612
Fixes Chrome crash introduced in NVDA pr #14647
Summary of the issue:
Google has detected crashes in Chrome when users are running NVDA.
Exact steps to reproduce are not known, but it is when an NVDA virtual buffer is destroyed. Could be on Chrome exit, NVDA exit, or closing a Chrome window.
Chrome issue: issues.chromium.org/issues/41487612
It shows that a COM object tries to be released from an RPC worker thread by NVDA's in-process code, which causes Chrome to crash.
NVDA pr #14647 introduced code to hold a reference to the document root accessible on the virtual buffer, so that NVDA could check if the document had died. However, it is this COM object that is automatically released when the virtual buffer id destroyed from an RPC worker thread.
The COM object should really however be released when the virtual buffer is terminated in the correct UI thread, before destruction.
Description of user facing changes
No longer cause Google Chrome to crash when closing a document or exiting Chrome.
Description of development approach
VBufBackend_gecko_ia2::renderThread_terminate: correctly release the document root accessible.
VBufBackend_gecko_ia2's destructor: in the very unlikely case where the VBufBackend_gecko_ia2::renderThread_terminate has not been called, detach the document root accessible, leaking it rather than inappropriately releasing it on the wrong thread.