• Kevin Babbitt's avatar
    Move printer handler tasks to the UI thread on Windows · 2e0b5c5c
    Kevin Babbitt authored
    We observed an issue in Microsoft Edge where a certain printer driver
    was being called on two different threads simultaneously and reacted
    by making an unbalanced CoUninitialize() call on the browser UI thread.
    If this happens enough times, the CoInitialize() count of the UI thread
    will eventually drop to zero and cause problems when, for example,
    out-of-process accessibility clients attempt to access objects that are
    only safe to call on the UI thread - the COM marshaler will see that
    the UI thread is in the implicit MTA and assume that these objects can
    be called from any MTA thread. I haven't successfully reproduced the
    same issue in Chrome, but the threading pattern for printer driver
    calls is the same, so the potential for it to occur is there.
    
    Existing code comments document that some Windows printer drivers are
    only safe to call from the UI thread. Accordingly, this CL addresses
    the issue by moving work done by the local printer handler from a
    generic task runner thread to the browser UI thread on Windows.
    
    Bug: 1065145
    Change-Id: Ic20872cb33bfb6c94381059578c2055cb1a9a1eb
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135054
    Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
    Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#756356}
    2e0b5c5c
thread_restrictions.h 22.3 KB