From 48c7c856a30ec1503c2294f72242a119d4f88c62 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Tue, 21 May 2024 12:10:21 +0900 Subject: [PATCH] Run parsing of vrm files on a thread pool. --- Assets/VRM10/Runtime/IO/Vrm10.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10.cs b/Assets/VRM10/Runtime/IO/Vrm10.cs index 27be68bf4..fc636e5c5 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10.cs @@ -52,7 +52,11 @@ namespace UniVRM10 ? new RuntimeOnlyAwaitCaller() : new ImmediateCaller(); - using var gltfData = new GlbLowLevelParser(path, await File.ReadAllBytesAsync(path, ct)).Parse(); + using var gltfData = await awaitCaller.Run(() => + { + var bytes = File.ReadAllBytes(path); + return new GlbLowLevelParser(path, bytes).Parse(); + }); return await LoadAsync( gltfData, canLoadVrm0X, @@ -96,7 +100,7 @@ namespace UniVRM10 ? new RuntimeOnlyAwaitCaller() : new ImmediateCaller(); - using var gltfData = new GlbLowLevelParser(string.Empty, bytes).Parse(); + using var gltfData = await awaitCaller.Run(() => new GlbLowLevelParser(string.Empty, bytes).Parse()); return await LoadAsync( gltfData, canLoadVrm0X,