PSA Garbage Collection crash UrhoSurface.Show (Android)

In my project i do some initialization in page constructor and then OnAppearing calls UrhoSurface.Show. If during Show execution a GC run is needed i get a crash with error :

System.NullReferenceException: Object reference not set to an instance of an object. at Urho.Droid.UrhoSurface+<SetSdlMain>c__AnonStorey2.<>m__0 (System.IntPtr _) [0x00000]

I tested it with an empty Urho Application getting created it Show like this:

urhoTest = await urhoSurface.Show<UrhoTest>(new ApplicationOptions(assetsFolder: null) { Orientation = ApplicationOptions.OrientationType.Landscape });

If i add GC.Collect() before calling UrhoSurface.Show everything works without crashes.
I use Urhosharp.Forms 1.2.21 from NuGet, not sure if it is still a problem in the current git hub version.
Just wanted to share this info, not sure if it's a bug or expected behavior.

Posts

  • NickWhitehurstNickWhitehurst GBMember ✭✭

    Massive thanks for the GC.Collect() work around!!

    Wasted hours on this, couldn't work out what was causing it.

Sign In or Register to comment.