Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Anonymous's avatar
Anonymous
5 years ago

ONSPPropagationGeometry loading from file is broken on Quest.

In the file ONSPPropagationGeometry the ReadFile method tries to read directly from Stream Assets, but on Android this has to be done using a UnityWebRequest. The code below is a workaround that reads the file out of streaming assets and saves it to persistent data. I just tried this on Quest and it seems to work.

 

Just need to replace these two methods:

void CreatePropagationGeometry()
{
// Create Geometry
if (ONSPPropagation.Interface.CreateAudioGeometry(out geometryHandle) != OSPSuccess)
{
throw new Exception("Unable to create geometry handle");
}

// Upload Mesh
if (!string.IsNullOrEmpty(filePath) && fileEnabled && Application.isPlaying)
{
ReadFile(success => {
if (!success)
{
Debug.LogError("Failed to read file, attempting to regenerate audio geometry");

// We should not try to upload data dynamically if data already exists
UploadGeometry();
}
});
}
else
{
UploadGeometry();
}
}

public void ReadFile(Action<bool> callback) {
string geoFilePath = filePath;

if (string.IsNullOrEmpty(geoFilePath))
{
Debug.LogError("Invalid mesh file path");
callback?.Invoke(false);
}

#if UNITY_ANDROID
if (geoFilePath.StartsWith("jar:")) {
// strip the apk prefix off the file uri.
var splithPath = geoFilePath.Split('!');
var dataPath = Path.Combine(Application.persistentDataPath, splithPath[1].Substring(1));

if (File.Exists(dataPath)) {
geoFilePath = dataPath;
}
else {
// read the file out of the apk and save it to persistent data.
var request = UnityWebRequest.Get(filePath).SendWebRequest();

request.completed += delegate(AsyncOperation operation) {
var asyncWebOp = operation as UnityWebRequestAsyncOperation;

if (asyncWebOp.webRequest.result == UnityWebRequest.Result.Success) {
var directory = Path.GetDirectoryName(dataPath);

Directory.CreateDirectory(directory);

File.WriteAllBytes(dataPath, asyncWebOp.webRequest.downloadHandler.data);

// now that the file's in place, try again.
ReadFile(callback);
}
else {
Debug.LogError($"couldn't retrieve geo file: \"{filePath}\"");
callback?.Invoke(false);
}
};

return;
}
}
#endif

if (ONSPPropagation.Interface.AudioGeometryReadMeshFile(geometryHandle, geoFilePath) != OSPSuccess)
{
Debug.LogError("Error reading mesh file " + geoFilePath);
callback?.Invoke(false);
}

callback?.Invoke(true);
}

 

8 Replies

Replies have been turned off for this discussion
  • Anonymous's avatar
    Anonymous

    Whoops, missed a "!" in above code.

    • Capraise's avatar
      Capraise
      Honored Guest

      Great!! This is working perfectly. Thank you very much!

      • Anonymous's avatar
        Anonymous

        Keep in mind there are still issues with this workaround. If you update your build with new geometry you'll need to delete the files in persistent data, otherwise you'll still only get old geometry on the headset.

         

        Also, I found the Oculus Spatializer crushed the Quest's CPU, making it nearly unusable (application running below 70fps on Quest 2). You might want to spend a day investigating Steam Audio (which works on Quest) if you're seeing similar performance issues.

         

        https://valvesoftware.github.io/steam-audio/downloads.html

  • Anonymous's avatar
    Anonymous

    Persistent data does get erased when you uninstall the apk, but if you push a new build from your PC to your Quest the persistent data doesn't get cleared. It depends on your workflow how big a problem this will be.

     

    Oculus should really fix this issue, instead of people relying on a workaround.

    • Capraise's avatar
      Capraise
      Honored Guest

      Thanks for those infos!

      I hope, it gets fixed soon. It’s a bit absurd that this doesn’t properly work on their main hardware. But from the log, I’m assuming that the geometry gets recalculated on the headset when not finding the files. It sounded different than in the editor though, so I’m a bit sceptical.

      Thank You for the clarification!

       

  • Anonymous's avatar
    Anonymous

    Does anyone have time to see if this is still broken in Oculus Integration v31? Looking at the C# it doesn't look fixed, but I don't have time to spend a day testing it.

    • Capraise's avatar
      Capraise
      Honored Guest

      Yes, it still hasn't corrected the reading those files, the same error occurs.

      It just keeps reuploading the geometry which kind of has the same effect I believe? It just makes those files redundant...