• kalman's avatar
    Add fallback mechanism to release Extension ports if the JS context has been destroyed. · 70c00e24
    kalman authored
    The bug is that chrome.runtime.sendMessage looks for when its callback is
    garbage collected, and when it is, close the associated port. It's important to
    close the port to notify the other end of the closure, cleanup renderer state
    both locally and on that other end, and potentially browser state.
    
    Unfortunately the port management is implemented in JS itself, and port
    releasing needs to go through JS. The problem is that it's not possible to call
    into JS while in the process of garbage collection, so we delay it, by which
    point the JS context may have been destroyed and again it's not possible to
    call into JS. We fixed the former case a while ago, and this patch fixes the
    latter.
    
    BUG=471599
    R=rockot@chromium.org
    
    Review URL: https://codereview.chromium.org/1136953017
    
    Cr-Commit-Position: refs/heads/master@{#330234}
    70c00e24
messaging.js 14.8 KB