Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze frame during runtime loading in Android #686

Open
ChocolateRacoon opened this issue Mar 27, 2024 · 0 comments
Open

Freeze frame during runtime loading in Android #686

ChocolateRacoon opened this issue Mar 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ChocolateRacoon
Copy link

Hello,

Could you please tell me if there is any way to get rid of freeze frames?

As far as I understand, the use of IDeferAgent is intended specifically for loading multiple models and increases the frame rate by queuing. Freeze frames occur even when loading one model.

Files

Model (glb): https://sketchfab.com/3d-models/warcraft-3-alliance-footmanfanmade-201452e568064aedadccfafb668ef6a5

Script

using System.IO;
using System.Threading.Tasks;
using GLTFast;
using UnityEngine;

namespace GLTFLoading
{
    public class GltfLoader : MonoBehaviour
    {
        [SerializeField] private string fileName = "Footman_RIG.glb";
        [SerializeField] [Range(.01f, 5f)] private float frameBudget = 0.1f;
        private GltfImport _gltf;

        async void Start()
        {
            fileName = Path.Combine(Application.persistentDataPath, fileName);
            Debug.Log($"Path for file = {fileName}");
            await LoadGltfBinaryFromMemory(transform);
        }
        
        private async Task<bool> LoadGltfBinaryFromMemory(Transform parent)
        {
            TimeBudgetPerFrameDeferAgent deferAgent = parent.gameObject.AddComponent<TimeBudgetPerFrameDeferAgent>();
            deferAgent.SetFrameBudget(frameBudget);
            GltfImport.SetDefaultDeferAgent(deferAgent);
            ImportSettings importSettings = new()
            {
                AnimationMethod = AnimationMethod.Mecanim,
                AnisotropicFilterLevel = 3,
                GenerateMipMaps = true
            };
            var success = await _gltf.Load(fileName, importSettings); // Frame freeze is here
            if (success)
                return await _gltf.InstantiateMainSceneAsync(parent);
            
            return success;
        }

    }
}

To Reproduce

Steps to reproduce the behavior:

  1. Create URP unity project
  2. Create scene
  3. Add the script (you can see it above) to scene
  4. Build the application
  5. Install the app on the device, download the model and place the model in the Persistence Data Path
  6. Open the app
  7. See frame freeze

Expected behavior

We get a frame freeze

Video

Load.gltf.from.storage.mp4

Additional data

  • glTFast version 6.0.1
  • Unity version 2022.3.16f1
  • URP 14.0.9
  • Platform: Android

Device

  • Meta Quest 3 (OS version SQ3A220605.009.A1), Oculus Quest 2

Optional

As I understand, parameter
GenerateMipMaps = true

is very hard for the app.

Setting this parameter to False reduced the peaks (according to the profiler data), but it still doesn't look good. Below I present the profiler data when loading GLTF via gltf fast

GenerateMipMaps = true

image

GenerateMipMaps = false

image

@ChocolateRacoon ChocolateRacoon added the bug Something isn't working label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant