Backed out 2 changesets (bug 1865921) for causing failures on test_device_lost.html. CLOSED TREE
Backed out changeset 39cf0feca383 (bug 1865921) Backed out changeset b0f89dfa3291 (bug 1865921)
This commit is contained in:
@@ -136,14 +136,15 @@ void Device::ResolveLost(Maybe<dom::GPUDeviceLostReason> aReason,
|
||||
// Promise doesn't exist? Maybe out of memory.
|
||||
return;
|
||||
}
|
||||
if (!lostPromise->PromiseObj()) {
|
||||
// The underlying JS object is gone.
|
||||
return;
|
||||
}
|
||||
if (lostPromise->State() != dom::Promise::PromiseState::Pending) {
|
||||
// lostPromise was already resolved or rejected.
|
||||
return;
|
||||
}
|
||||
if (!lostPromise->PromiseObj()) {
|
||||
// The underlying JS object is gone.
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<DeviceLostInfo> info;
|
||||
if (aReason.isSome()) {
|
||||
info = MakeRefPtr<DeviceLostInfo>(GetParentObject(), *aReason, aMessage);
|
||||
|
||||
@@ -229,11 +229,11 @@ void WebGPUChild::RegisterDevice(Device* const aDevice) {
|
||||
mDeviceMap.insert({aDevice->mId, aDevice});
|
||||
}
|
||||
|
||||
void WebGPUChild::UnregisterDevice(RawId aDeviceId) {
|
||||
void WebGPUChild::UnregisterDevice(RawId aId) {
|
||||
mDeviceMap.erase(aId);
|
||||
if (IsOpen()) {
|
||||
SendDeviceDrop(aDeviceId);
|
||||
SendDeviceDrop(aId);
|
||||
}
|
||||
mDeviceMap.erase(aDeviceId);
|
||||
}
|
||||
|
||||
void WebGPUChild::FreeUnregisteredInParentDevice(RawId aId) {
|
||||
|
||||
@@ -323,12 +323,7 @@ WebGPUParent::WebGPUParent()
|
||||
&WebGPUParent::MaintainDevices);
|
||||
}
|
||||
|
||||
WebGPUParent::~WebGPUParent() {
|
||||
MOZ_ASSERT(mErrorScopeStackByDevice.empty(),
|
||||
"All Devices should have been dropped.");
|
||||
MOZ_ASSERT(mDeviceLostRequests.empty(),
|
||||
"There should be no pending DeviceLostRequest callbacks.");
|
||||
}
|
||||
WebGPUParent::~WebGPUParent() = default;
|
||||
|
||||
void WebGPUParent::MaintainDevices() {
|
||||
ffi::wgpu_server_poll_all_devices(mContext.get(), false);
|
||||
@@ -440,33 +435,6 @@ ipc::IPCResult WebGPUParent::RecvInstanceRequestAdapter(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
/* static */ void WebGPUParent::DeviceLostCallback(uint8_t* aUserData,
|
||||
uint8_t aReason,
|
||||
const char* aMessage) {
|
||||
DeviceLostRequest* req = reinterpret_cast<DeviceLostRequest*>(aUserData);
|
||||
if (!req->mParent) {
|
||||
// Parent is dead, never mind.
|
||||
return;
|
||||
}
|
||||
|
||||
RawId deviceId = req->mDeviceId;
|
||||
|
||||
// If aReason is 0, that corresponds to the "unknown" reason, which
|
||||
// we treat as a Nothing() value. Any other value (which is positive)
|
||||
// is mapped to the GPUDeviceLostReason values by subtracting 1.
|
||||
Maybe<uint8_t> reason;
|
||||
if (aReason > 0) {
|
||||
uint8_t mappedReasonValue = (aReason - 1u);
|
||||
reason = Some(mappedReasonValue);
|
||||
}
|
||||
nsAutoCString message(aMessage);
|
||||
req->mParent->LoseDevice(deviceId, reason, message);
|
||||
|
||||
// We're no longer tracking the memory for this callback, so erase
|
||||
// it to ensure we don't leak memory.
|
||||
req->mParent->mDeviceLostRequests.erase(deviceId);
|
||||
}
|
||||
|
||||
ipc::IPCResult WebGPUParent::RecvAdapterRequestDevice(
|
||||
RawId aAdapterId, const ipc::ByteBuf& aByteBuf, RawId aDeviceId,
|
||||
AdapterRequestDeviceResolver&& resolver) {
|
||||
@@ -479,25 +447,11 @@ ipc::IPCResult WebGPUParent::RecvAdapterRequestDevice(
|
||||
MOZ_ASSERT(maybeError.isSome());
|
||||
LoseDevice(aDeviceId, Some(reasonDestroyed), maybeError->message);
|
||||
resolver(false);
|
||||
return IPC_OK();
|
||||
} else {
|
||||
mErrorScopeStackByDevice.insert({aDeviceId, {}});
|
||||
resolver(true);
|
||||
}
|
||||
|
||||
mErrorScopeStackByDevice.insert({aDeviceId, {}});
|
||||
|
||||
// Setup the device lost callback.
|
||||
std::unique_ptr<DeviceLostRequest> req(
|
||||
new DeviceLostRequest{this, aDeviceId});
|
||||
auto iter = mDeviceLostRequests.insert({aDeviceId, std::move(req)});
|
||||
MOZ_ASSERT(iter.second, "Should be able to insert DeviceLostRequest.");
|
||||
auto record = iter.first;
|
||||
DeviceLostRequest* req_shadow = (record->second).get();
|
||||
ffi::WGPUDeviceLostClosureC callback = {
|
||||
&DeviceLostCallback, reinterpret_cast<uint8_t*>(req_shadow)};
|
||||
ffi::wgpu_server_set_device_lost_callback(mContext.get(), aDeviceId,
|
||||
callback);
|
||||
|
||||
resolver(true);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
HANDLE handle =
|
||||
wgpu_server_get_device_fence_handle(mContext.get(), aDeviceId);
|
||||
@@ -521,9 +475,6 @@ ipc::IPCResult WebGPUParent::RecvDeviceDestroy(RawId aDeviceId) {
|
||||
|
||||
ipc::IPCResult WebGPUParent::RecvDeviceDrop(RawId aDeviceId) {
|
||||
ffi::wgpu_server_device_drop(mContext.get(), aDeviceId);
|
||||
MOZ_ASSERT(mDeviceLostRequests.find(aDeviceId) == mDeviceLostRequests.end(),
|
||||
"DeviceLostRequest should have been invoked, then erased.");
|
||||
|
||||
mErrorScopeStackByDevice.erase(aDeviceId);
|
||||
mLostDeviceIds.Remove(aDeviceId);
|
||||
return IPC_OK();
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "mozilla/webgpu/ffi/wgpu.h"
|
||||
#include "mozilla/webgpu/PWebGPUParent.h"
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
@@ -41,7 +40,7 @@ class PresentationData;
|
||||
// needs to be dropped when the last reference to it dies on the child
|
||||
// process.
|
||||
|
||||
class WebGPUParent final : public PWebGPUParent, public SupportsWeakPtr {
|
||||
class WebGPUParent final : public PWebGPUParent {
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGPUParent, override)
|
||||
|
||||
public:
|
||||
@@ -170,8 +169,6 @@ class WebGPUParent final : public PWebGPUParent, public SupportsWeakPtr {
|
||||
private:
|
||||
static void MapCallback(ffi::WGPUBufferMapAsyncStatus aStatus,
|
||||
uint8_t* aUserData);
|
||||
static void DeviceLostCallback(uint8_t* aUserData, uint8_t aReason,
|
||||
const char* aMessage);
|
||||
void DeallocBufferShmem(RawId aBufferId);
|
||||
|
||||
void RemoveExternalTexture(RawId aTextureId);
|
||||
@@ -218,16 +215,6 @@ class WebGPUParent final : public PWebGPUParent, public SupportsWeakPtr {
|
||||
|
||||
// Shared handle of wgpu device's fence.
|
||||
RefPtr<gfx::FileHandleWrapper> mFenceHandle;
|
||||
|
||||
// Store DeviceLostRequest structs for each device as unique_ptrs mapped
|
||||
// to their device ids. We keep these unique_ptrs alive as long as the
|
||||
// device is alive.
|
||||
struct DeviceLostRequest {
|
||||
WeakPtr<WebGPUParent> mParent;
|
||||
RawId mDeviceId;
|
||||
};
|
||||
std::unordered_map<RawId, std::unique_ptr<DeviceLostRequest>>
|
||||
mDeviceLostRequests;
|
||||
};
|
||||
|
||||
} // namespace webgpu
|
||||
|
||||
@@ -32,7 +32,6 @@ fail-if = [
|
||||
["test_buffer_mapping_invalid_device.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_command_buffer_creation.html"]
|
||||
@@ -44,7 +43,6 @@ fail-if = [
|
||||
["test_context_configure.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_device_creation.html"]
|
||||
@@ -53,16 +51,9 @@ fail-if = [
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_device_lost.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_double_encoder_finish.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_enabled.html"]
|
||||
@@ -94,7 +85,6 @@ fail-if = [
|
||||
["test_queue_write_invalid_device.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_submit_compute_empty.html"]
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
ok(
|
||||
SpecialPowers.getBoolPref("dom.webgpu.enabled"),
|
||||
"Pref should be enabled."
|
||||
);
|
||||
|
||||
const destroy_causes_lost = async function () {
|
||||
const adapter = await navigator.gpu.requestAdapter();
|
||||
const limits = adapter.limits;
|
||||
const features = adapter.features;
|
||||
const device = await adapter.requestDevice();
|
||||
ok(device !== undefined, "device !== undefined");
|
||||
|
||||
const lostPromise = device.lost;
|
||||
device.destroy();
|
||||
const deviceLostReason = await lostPromise;
|
||||
|
||||
is(
|
||||
deviceLostReason.reason,
|
||||
"destroyed",
|
||||
"Destroy reason should correspond to GPUDeviceLostReason.destroyed"
|
||||
);
|
||||
is(deviceLostReason.message, "", "Destroy message should be blank");
|
||||
};
|
||||
|
||||
const drop_causes_lost_is_unobservable = async function () {
|
||||
const adapter = await navigator.gpu.requestAdapter();
|
||||
const limits = adapter.limits;
|
||||
const features = adapter.features;
|
||||
|
||||
let lostPromise;
|
||||
// Create a scope with a device that will go out of scope
|
||||
// and then be dropped.
|
||||
{
|
||||
const device = await adapter.requestDevice();
|
||||
ok(device !== undefined, "device !== undefined");
|
||||
|
||||
lostPromise = device.lost;
|
||||
}
|
||||
|
||||
SimpleTest.requestFlakyTimeout(
|
||||
"Racing against promise that should never resolve."
|
||||
);
|
||||
const TIMEOUT_MS = 5000;
|
||||
let timeoutPromise = new Promise(resolve => {
|
||||
let timeoutValue = { reason: "timeout" };
|
||||
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
|
||||
setTimeout(() => resolve(timeoutValue), TIMEOUT_MS);
|
||||
});
|
||||
|
||||
const firstPromise = await Promise.race([lostPromise, timeoutPromise]);
|
||||
is(
|
||||
firstPromise.reason,
|
||||
"timeout",
|
||||
"timeoutPromise should return before lostPromise."
|
||||
);
|
||||
};
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
destroy_causes_lost()
|
||||
.then(drop_causes_lost_is_unobservable())
|
||||
.catch(e => ok(false, "Unhandled exception " + e))
|
||||
.finally(SimpleTest.finish());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -317,11 +317,6 @@ pub extern "C" fn wgpu_server_device_drop(global: &Global, self_id: id::DeviceId
|
||||
gfx_select!(self_id => global.device_drop(self_id))
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wgpu_server_set_device_lost_callback(global: &Global, self_id: id::DeviceId, callback: wgc::device::DeviceLostClosureC) {
|
||||
gfx_select!(self_id => global.device_set_device_lost_closure(self_id, wgc::device::DeviceLostClosure::from_c(callback)));
|
||||
}
|
||||
|
||||
impl ShaderModuleCompilationMessage {
|
||||
fn set_error(&mut self, error: &CreateShaderModuleError, source: &str) {
|
||||
// The WebGPU spec says that if the message doesn't point to a particular position in
|
||||
|
||||
Reference in New Issue
Block a user