• Jiawei Shao's avatar
    WebGPU: Don't destroy WebGPUSerializer in the destructor of GPUDevice · 86511b98
    Jiawei Shao authored
    This patch intends to fix a crash issue when GPUDevice is destroyed
    before the destruction of any other WebGPU objects that are created
    from it.
    
    Without this patch, when a GPUDevice is destroyed its related
    WebGPUSerializer is also destroyed immediately, which causes crash
    when any other WebGPU object which belongs to this GPUDevice is
    destroyed afterwards.
    
    In this patch, we introduce DawnDeviceClientSerializerHolder to
    manage the reference count of all the WebGPU objects that belong to
    one device_client_id (relates to one WebGPUSerializer).
    - When GPUDevice is created,
      scopted_ptr<DawnDeviceClientSerializerHolder> is also created with
      dawn_control_client and device_client_id.
    - When other WebGPU objects are created from a GPUDevice, they will all
      get a reference of scopted_ptr<DawnDeviceClientSerializerHolder> from
      the GPUDevice
    - The WebGPUSerializer will only be released in the destructor of
      scopted_ptr<DawnDeviceClientSerializerHolder> (that should be the
      time when the GPUDevice and all the WebGPU objects that are created
      from it are released).
    
    Note that scoped_refptr<DawnControlClientHolder> is referenced twice in
    GPUDevice and other WebGPU objects that are created from it as they are
    still inherited from DawnObjectBase. We will fix this issue in the next
    patch.
    
    BUG=chromium:996713, chromium:1072833
    
    Change-Id: Ibb83f9c906fa38f15712ba0f20c67e4929ba3c0e
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2192672Reviewed-by: default avatarAustin Eng <enga@chromium.org>
    Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
    Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
    Cr-Commit-Position: refs/heads/master@{#768579}
    86511b98
dawn_object.cc 1.83 KB