Changeset 263447 in webkit


Ignore:
Timestamp:
Jun 24, 2020 1:50:05 AM (4 years ago)
Author:
svillar@igalia.com
Message:

[WebXR] Fix PlatformXR initialization/destruction
https://bugs.webkit.org/show_bug.cgi?id=213509

Reviewed by Youenn Fablet.

There were two different issues, one at creation time and the other one at destruction. At creation
time we were not calling construct() for the LazyNeverDestroyed object. That was making the WebProcess
crash in Debug builds. At destruction time we were calling xrDestroyInstance() without checking that the
passed instance was a valid one, although OpenXR implementations deal with it the spec is pretty clear.

  • platform/xr/PlatformXR.h: Mark LazyNeverDestroyed as friend and default constructor&destructor.
  • platform/xr/openxr/PlatformXROpenXR.cpp:

(PlatformXR::Instance::Impl::~Impl): Check that instance is not XR_NULL_HANDLE before destroying.
(PlatformXR::Instance::singleton): Call construct() on the Lazy instance.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r263446 r263447  
     12020-06-23  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [WebXR] Fix PlatformXR initialization/destruction
     4        https://bugs.webkit.org/show_bug.cgi?id=213509
     5
     6        Reviewed by Youenn Fablet.
     7
     8        There were two different issues, one at creation time and the other one at destruction. At creation
     9        time we were not calling construct() for the LazyNeverDestroyed object. That was making the WebProcess
     10        crash in Debug builds. At destruction time we were calling xrDestroyInstance() without checking that the
     11        passed instance was a valid one, although OpenXR implementations deal with it the spec is pretty clear.
     12
     13        * platform/xr/PlatformXR.h: Mark LazyNeverDestroyed as friend and default constructor&destructor.
     14        * platform/xr/openxr/PlatformXROpenXR.cpp:
     15        (PlatformXR::Instance::Impl::~Impl): Check that instance is not XR_NULL_HANDLE before destroying.
     16        (PlatformXR::Instance::singleton): Call construct() on the Lazy instance.
     17
    1182020-06-24  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/Source/WebCore/platform/xr/PlatformXR.h

    r262838 r263447  
    2121#include <memory>
    2222#include <wtf/HashMap.h>
     23#include <wtf/UniqueRef.h>
    2324#include <wtf/Vector.h>
    2425#include <wtf/WeakPtr.h>
     
    7071    const Vector<std::unique_ptr<Device>>& immersiveXRDevices() const { return m_immersiveXRDevices; }
    7172private:
     73    friend LazyNeverDestroyed<Instance>;
    7274    Instance();
    73     ~Instance();
     75    ~Instance() = default;
    7476
    7577    struct Impl;
    76     std::unique_ptr<Impl> m_impl;
     78    UniqueRef<Impl> m_impl;
    7779
    7880    Vector<std::unique_ptr<Device>> m_immersiveXRDevices;
  • trunk/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp

    r262855 r263447  
    163163Instance::Impl::~Impl()
    164164{
    165     xrDestroyInstance(m_instance);
     165    if (m_instance != XR_NULL_HANDLE)
     166        xrDestroyInstance(m_instance);
    166167}
    167168
     
    214215    std::call_once(s_onceFlag,
    215216        [&] {
    216             s_instance->m_impl = makeUnique<Impl>();
     217            s_instance.construct();
    217218        });
    218219    return s_instance.get();
    219220}
    220221
    221 Instance::Instance() = default;
    222 Instance::~Instance() = default;
     222Instance::Instance()
     223    : m_impl(makeUniqueRef<Impl>())
     224{
     225}
    223226
    224227void Instance::enumerateImmersiveXRDevices()
Note: See TracChangeset for help on using the changeset viewer.