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

grpc unity iOS: crash at Grpc.Core.Internal.PlatformApis.GetUnityRuntimePlatform on start up #19262

Closed
umegaya opened this issue Jun 6, 2019 · 8 comments

Comments

@umegaya
Copy link

umegaya commented Jun 6, 2019

What version of gRPC and what language are you using?

grpc_unity_package.1.22.0-dev.zip from daily build page.

What operating system (Linux, Windows,...) and version?

osx 10.14.4

What runtime / compiler are you using (e.g. python version or version of gcc)

Unity 2018.4.0f1

What did you do?

https://github.com/umegaya/mobile-game-http-latency-test/blob/master/client/Assets/Scripts/PingRunner.cs#L94

basically just try to invoke simple unary async call. note that android build from same codes run without any error.

What did you expect to see?

ios build can invoke unary call without error, as android version can.

What did you see instead?

error on creating channel object.

NullReferenceException: Object reference not set to an instance of an object.
  at Grpc.Core.Internal.PlatformApis.GetUnityRuntimePlatform () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Internal.NativeExtension.LoadNativeMethodsUnity () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Internal.NativeExtension..ctor () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Internal.NativeExtension.Get () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Internal.NativeMethods.Get () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.GrpcEnvironment.GrpcNativeInit () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.GrpcEnvironment..ctor () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.GrpcEnvironment.AddRef () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Channel..ctor (System.String target, Grpc.Core.ChannelCredentials credentials, System.Collections.Generic.IEnumerable`1[T] options) [0x00000] in <00000000000000000000000000000000>:0 
  at LatencyResearch.GrpcPing..ctor (System.String domain, System.String iaas) [0x00000] in <00000000000000000000000000000000>:0 
  at LatencyResearch.Measure+<Exec>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 

Anything else we should know about your project / environment?

  • I try .Net standard 2.0 and .Net 4.x for Api Compatibility Level, but both crashed same place
  • TROUBLESHOOTING.md does not works because error is happen before entering code c library.
@jtattermusch
Copy link
Contributor

This seems to be what's crashing:

public static string GetUnityRuntimePlatform()

I'm wondering why, the UnityEngine.Application.platform is not really something that could be missing in a working unity application.
https://docs.unity3d.com/ScriptReference/Application-platform.html

@stale
Copy link

stale bot commented Dec 21, 2019

This issue/PR has been automatically marked as stale because it has not had any update (including commits, comments, labels, milestones, etc) for 180 days. It will be closed automatically if no further update occurs in 1 day. Thank you for your contributions!

@blunoob
Copy link

blunoob commented Dec 22, 2019

I am still getting the same error on Unity 2019.2.6f1 when building for android with il2cpp. Is there any chance that the problem is not there in MagicOnion library?

I/Unity: >> e.Message >> Object reference not set to an instance of an object.
Exception : at Grpc.Core.Internal.PlatformApis.GetUnityRuntimePlatform () [0x00000] in <00000000000000000000000000000000>:0
at Grpc.Core.Internal.NativeExtension.LoadNativeMethodsUnity () [0x00000] in <00000000000000000000000000000000>:0
at Grpc.Core.Internal.NativeExtension..ctor () [0x00000] in <00000000000000000000000000000000>:0
at Grpc.Core.Internal.NativeExtension.Get () [0x00000] in <00000000000000000000000000000000>:0
at Grpc.Core.Internal.NativeMethods.Get () [0x00000] in <00000000000000000000000000000000>:0
at Grpc.Core.GrpcEnvironment.GrpcNativeInit () [0x00000] in <00000000000000000000000000000000>:0
at Grpc.Core.GrpcEnvironment..ctor () [0x00000] in <00000000000000000000000000000000>:0
at Grpc.Core.GrpcEnvironment.AddRef () [0x00000] in <00000000000000000000000000000000>:0
at Grpc.Core.Channel..ctor (System.String target, Grpc.Core.ChannelCredentials credentials, System.Collections.Generic.IEnume

@stale stale bot removed the disposition/stale label Dec 22, 2019
@blunoob
Copy link

blunoob commented Dec 29, 2019

The error is now gone. Looks like its fixed in the grpc daily build from yesterday.

@ogswr
Copy link

ogswr commented Dec 30, 2019

That's good to hear.

@stale
Copy link

stale bot commented May 6, 2020

This issue/PR has been automatically marked as stale because it has not had any update (including commits, comments, labels, milestones, etc) for 30 days. It will be closed automatically if no further update occurs in 7 day. Thank you for your contributions!

@ownrisk
Copy link

ownrisk commented May 7, 2020

It's seems to IL2CPP-ByteCodeStripping.

add file: /Assets/link.xml

<linker>
    <assembly fullname="UnityEngine">
        <type fullname="UnityEngine.Application" preserve="fields">
            <property name="platform"/>
        </type>
    </assembly>
</linker>

@stale stale bot removed the disposition/stale label May 7, 2020
@jtattermusch
Copy link
Contributor

Looks like the workaround #19262 (comment) has been confirmed and this also doesn't seem to be an issue in the grpc code. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants