Fix ResourceMemoryAllocation null dereference

Moves last TickImpl call during ShutDown to only be called if the
device was fully created.

Bug: dawn:400, chromium:1093639
Change-Id: I25437e3b33d0fc57f21e82c63bfb0fd4d9384175
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23123
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp
index 73bbcf9..211c321 100644
--- a/src/dawn_native/Device.cpp
+++ b/src/dawn_native/Device.cpp
@@ -152,6 +152,9 @@
             mErrorScopeTracker->Tick(GetCompletedCommandSerial());
             mFenceSignalTracker->Tick(GetCompletedCommandSerial());
             mMapRequestTracker->Tick(GetCompletedCommandSerial());
+            // call TickImpl once last time to clean up resources
+            // assert the errors are device loss so we can continue with destruction
+            AssertAndIgnoreDeviceLossError(TickImpl());
         }
 
         // At this point GPU operations are always finished, so we are in the disconnected state.
@@ -166,9 +169,6 @@
         mDynamicUploader = nullptr;
         mMapRequestTracker = nullptr;
 
-        // call TickImpl once last time to clean up resources
-        // assert the errors are device loss so we can continue with destruction
-        AssertAndIgnoreDeviceLossError(TickImpl());
         AssumeCommandsComplete();
         // Tell the backend that it can free all the objects now that the GPU timeline is empty.
         ShutDownImpl();