Merge pull request #2297 from Santarh/asyncLoad

Run parsing of vrm10 files on a thread pool.
This commit is contained in:
ousttrue 2024-05-30 17:25:05 +09:00 committed by GitHub
commit 7a5d0beb60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 2 deletions

View File

@ -52,7 +52,11 @@ namespace UniVRM10
? new RuntimeOnlyAwaitCaller()
: new ImmediateCaller();
using var gltfData = new GlbLowLevelParser(path, File.ReadAllBytes(path)).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,

View File

@ -0,0 +1,20 @@
using NUnit.Framework;
using VRMShaders;
namespace UniVRM10.Test
{
public sealed class Vrm10ApiTests
{
[Test]
public void LoadImmediately()
{
var loadTask = Vrm10.LoadPathAsync(
TestAsset.AliciaPath,
canLoadVrm0X: true,
awaitCaller: new ImmediateCaller()
);
Assert.AreEqual(true, loadTask.IsCompleted);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6bf6de3c68bf4a5994e2b5739f60b913
timeCreated: 1716261790