Hi everyone,
I want to use the Reactive Extensions of Microsoft to use the Reactive Programming pattern.
I imported the dll (at version 1.0, which is compatible with dotnet Framework 3.5) and it work perfectly on platform where JIT is available.
But, for iOS, the JIT compiler is not available and I ran into the error :
Attempting to JIT compile method
'System.Reactive.Concurrency.ScheduledItem`2<System.DateTimeOffset, System.Action>:.ctor(System.Reactive.Concurrency.IScheduler, System.Action, System.Func`3<System.Reactive.Concurrency.IScheduler, System.Action, System.IDisposable>, System.DateTimeOffset)' while running with --aot-only
The actual issue is that a generic method is called (System.Reactive.Concurrency.ScheduledItem:.ctor
) with a value type as parameter (System.DateTimeOffset
which is a struct) and such calls need to be generated by the JIT compiler
I tried several solutions, but they did not succeeded :
- I first wanted to for the aot compiler to include the required method. But,
System.Reactive.Concurrency.ScheduledItem
is not visible, so I can not reference the class. - I tried to call the first visible method explicitly, but It provokes the same issue.
- I tried to use a custom
IScheduler
(which use the Unity’s coroutine system to schedule items) that will not call theSystem.Reactive.Concurrency.CurrentThreadScheduler
(the default scheduler that create the issue). In order to force the use of this scheduler, I calledSubscribeOn
andObserveOn
on allSubject
I use asIObservable
. But, the issue still happens onSubscribe
call. - I wanted to replace somehow the default
IScheduler
, but It seems not possible to replace it. Anyway, I did not find a way to do it. - I planned to implement myself a subset of Rx features which would be simple and synchronous. But, it is a loss of time to reproduce a framework that already exists and was done by an entire team of Microsoft.
Currently, my plan is to create my own implementation. Well, this is not a good solution, but I did not find another way. Moreover, it raise another issue : How to choose a dll in the Assets folder depending on the platform selected ? (ie : I want to use Microsoft’s dll for jit platform and my implementation for aot platforms)
Well, I am a kind of stuck here, any idea will be greatly appreciated !