microsoft / microsoft/psi

PSI on Oculus Quest (Android)

Open
#263 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
574
Forks
104
Avg merge
19m
Merged PRs (30d)
1

Description

Hi! I'm trying to use PSI on an Oculus Quest in combination with StereoKit.
To start, I cloned the StereoKit universal template (https://github.com/StereoKit/SKTemplate-Universal) and added a Microsoft.Psi.Runtime NuGet package reference to the StereoKitApp project.
I adapted the first example from the Brief Introduction wiki page and added it to App.cs to test the basic functionality.

using Microsoft.Psi;
...
...
...
public void Init() {
...
...
...
    PsiTest();
}

public async void PsiTest() {
    await Task.Run(() => {
        try {
            using (var p = Pipeline.Create()) {
                var timer = Timers.Timer(p, TimeSpan.FromSeconds(0.1));
                timer.Do(t => Console.WriteLine(t));
                p.Run();
            }
        } catch (Exception ex) {
            Console.WriteLine("Message: ");
            Console.WriteLine(ex.Message);
            Console.WriteLine("InnerException: ");
            Console.WriteLine(ex.InnerException);
            Console.WriteLine("StackTrace: ");
            Console.WriteLine(ex.StackTrace);
            Console.WriteLine("");
        }
    });
}

When running this on desktop by setting the StereoKit_DotNet project as the startup project it works as expected; every 100ms a timestamp is printed to the console.
When setting the StereoKit_Android project as the startup project and deploying it to the Oculus Quest, the following exception is caught:

Message: 
The type initializer for 'Microsoft.Psi.Serialization.KnownSerializers' threw an exception.
InnerException: 
System.NullReferenceException: Object reference not set to an instance of an object.
  at System.TypeSpec.Resolve (System.Func`2[T,TResult] assemblyResolver, System.Func`4[T1,T2,T3,TResult] typeResolver, System.Boolean throwOnError, System.Boolean ignoreCase, System.Threading.StackCrawlMark& stackMark) [0x0008a] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System/TypeSpec.cs:322 
  at System.TypeNameParser.GetType (System.String typeName, System.Func`2[T,TResult] assemblyResolver, System.Func`4[T1,T2,T3,TResult] typeResolver, System.Boolean throwOnError, System.Boolean ignoreCase, System.Threading.StackCrawlMark& stackMark) [0x00006] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/ReferenceSources/TypeNameParser.cs:17 
  at System.Type.GetType (System.String typeName, System.Func`2[T,TResult] assemblyResolver, System.Func`4[T1,T2,T3,TResult] typeResolver) [0x00002] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/ReferenceSources/Type.cs:171 
  at Microsoft.Psi.TypeResolutionHelper.GetVerifiedType (System.String typeName) [0x00000] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Serialization.KnownSerializers.RegisterGenericSerializer (System.Type genericSerializer) [0x00033] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Serialization.KnownSerializers..ctor (System.Boolean isDefault, Microsoft.Psi.Common.RuntimeInfo runtimeVersion) [0x000ca] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Serialization.KnownSerializers..cctor () [0x00073] in <6bd4d33a21f248318e30737cf8f86d32>:0 
StackTrace: 
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
  at Microsoft.Psi.Serializer.IsImmutableType[T] () [0x00000] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.RecyclingPool.Create[T] (System.Diagnostics.StackTrace debugTrace) [0x00000] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Receiver`1[T]..ctor (System.Int32 id, System.String name, Microsoft.Psi.Executive.PipelineElement element, System.Object owner, System.Action`1[T] onReceived, Microsoft.Psi.Scheduling.SynchronizationLock context, Microsoft.Psi.Pipeline pipeline, System.Boolean enforceIsolation) [0x000b3] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Pipeline.CreateReceiver[T] (System.Object owner, System.Action`1[T] action, System.String name, System.Boolean autoClone) [0x0001c] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Pipeline.CreateReceiver[T] (System.Object owner, System.Action`2[T1,T2] action, System.String name, System.Boolean autoClone) [0x0000d] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Components.ConsumerProducer`2[TIn,TOut]..ctor (Microsoft.Psi.Pipeline pipeline, System.String name) [0x00030] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Components.Processor`2[TIn,TOut]..ctor (Microsoft.Psi.Pipeline pipeline, System.Action`3[T1,T2,T3] transform, System.Action`2[T1,T2] onClose, System.String name) [0x0000d] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Operators.Process[TIn,TOut] (Microsoft.Psi.IProducer`1[TOut] source, System.Action`3[T1,T2,T3] transform, Microsoft.Psi.DeliveryPolicy`1[T] deliveryPolicy, System.String name) [0x0000b] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Operators.Do[T] (Microsoft.Psi.IProducer`1[TOut] source, System.Action`2[T1,T2] action, Microsoft.Psi.DeliveryPolicy`1[T] deliveryPolicy, System.String name) [0x0000d] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at Microsoft.Psi.Operators.Do[T] (Microsoft.Psi.IProducer`1[TOut] source, System.Action`1[T] action, Microsoft.Psi.DeliveryPolicy`1[T] deliveryPolicy, System.String name) [0x0000d] in <6bd4d33a21f248318e30737cf8f86d32>:0 
  at StereoKitApp.App+<>c.<PsiTest>b__7_0 () [0x00029] in F:\PSI_questTest\SKTemplate-Universal\App.cs:36 

I tried creating a new Android App (Xamarin) project in which I added the same PsiTest() function and tried running it on my Android phone which resulted in the same error.

I read on the Mixed Reality Overview wiki page that the Oculus Quest is not tested but that it should be possible to target it (with a little extra effort).
Could you point me in the right direction on how to get this to work? Thanks in advance!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the App.cs PsiTest entry point and the Microsoft.Psi.Runtime package reference, then trace the KnownSerializers and TypeResolutionHelper exception shown in the Android stack trace. Compare the working desktop run with the Android and Xamarin reproductions; done means the basic timer pipeline runs on the Oculus Quest or Android without this initialization exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.