Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Crash in JNI / GetNetworkProxySettings

Discussion in 'Android' started by spatial_io, Nov 17, 2020.

  1. spatial_io

    spatial_io

    Joined:
    Jul 3, 2017
    Posts:
    21
    In the wild I'm seeing a lot of crashes like this:

    Code (CSharp):
    1. [ 00 ] 0x7f8ada9ed8
    2. [ 01 ] 0x7f8ada6c80
    3. [ 02 ] 0x7f8ad54ac0
    4. [ 03 ] 0x7f8ad4cdcc
    5. [ 04 ] 0x7f899faabc
    6. [ 05 ] 0x7f89663664
    7. [ 06 ] 0x7f897f05c0
    8. [ 07 ] 0x7f898f5eb4
    9. [ 08 ] 0x7f898e20a0
    10. [ 09 ] jni::NewObject(_jclass*, _jmethodID*, ...)
    11. [ 10 ] UnityPlayerJavaWrapper::GetNetworkProxySettings(char const*)
    12. [ 11 ] 0x7f8ad4e204
    I'm able to reproduce in my app by (1) connecting to a network endpoint with a proxy and then (2) disconnecting the proxy. It takes about 5-10 seconds. We send traffic regularly (logs).

    A few questions:
    1. Is there any way to access the source code for UnityPlayerJavaWrapper::GetNetworkProxySettings? I didn't see it in the CS sources.
    2. What could be causing this crash?

    P.S. A similar crash I'm seeing a lot of:
    Code (CSharp):
    1. [ 00 ] 0x7f8150ded8
    2. [ 01 ] 0x7f8150ac80
    3. [ 02 ] 0x7f814b8ac0
    4. [ 03 ] 0x7f814b0dcc
    5. [ 04 ] 0x7f807faabc
    6. [ 05 ] 0x7f80463664
    7. [ 06 ] 0x7f805f05c0
    8. [ 07 ] 0x7f80701534
    9. [ 08 ] jni::NewStringUTF(char const*)
    10. [ 09 ] java::lang::String::String(char const*)
    11. [ 10 ] UnityPlayerJavaWrapper::GetNetworkProxySettings(char const*)
    12. [ 11 ] 0x7f814b2204
     
  2. spatial_io

    spatial_io

    Joined:
    Jul 3, 2017
    Posts:
    21
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    This is part of code used to obtain system proxy settings for network requests, such as UnityWebRequest. Does logcat contain any more info just before that crash?
     
  4. spatial_io

    spatial_io

    Joined:
    Jul 3, 2017
    Posts:
    21
    Aurimas-Cernius:
    Here are the logs I get when reproducing locally.
     

    Attached Files:

  5. spatial_io

    spatial_io

    Joined:
    Jul 3, 2017
    Posts:
    21
    This seems especially relevant:
    Code (CSharp):
    1.  
    2. 11-30 16:18:40.466   719  4600 I [CT]    : CONSTELLATION: R: Detected motion/button event. Leaving static state.
    3. 11-30 16:18:40.521  6520  6675 I VrApi   : FPS=65/72,Prd=41ms,Tear=0,Early=18,Stale=11,VSnc=1,Lat=1,Fov=0D,CPU4/GPU=4/4,2304/670MHz,OC=FF,TA=0/0/0,SP=N/N/N,Mem=1804MHz,Free=763MB,PSM=0,PLS=0,Temp=33.0C/0.0C,TW=1.99ms,App=8.83ms,GD=0.00ms,CPU&GPU=12.08ms,LCnt=1,GPU%=0.38,CPU%=0.83(W0.86),DSF=1.00
    4. 11-30 16:18:40.548  1768  1778 I art     : Background sticky concurrent mark sweep GC freed 30012(8MB) AllocSpace objects, 4(104KB) LOS objects, 40% free, 12MB/21MB, paused 17.356ms total 71.038ms
    5. 11-30 16:18:40.594   719  4600 I [CT]    : CONSTELLATION: R: Detected static motion w/ tracked pos and w/o button event, applying constant pose priors.
    6. 11-30 16:18:40.622   719  4600 I [CT]    : CONSTELLATION:IMU_STATUS: 3192c751d893bab7: [FusionTracked=1.000, OutputTracked=1.000, OutputValid=1.000] [AccelSat=0.000, GyroSat=0.000]
    7. 11-30 16:18:40.959  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132] JNI ERROR (app bug): local reference table overflow (max=512)
    8. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132] local reference table dump:
    9. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]   Last 10 entries (of 512):
    10. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       511: 0x1307aee0 java.lang.String "10.0.0.10:8080"
    11. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       510: 0x132179e0 java.lang.String "https://logs-01.... (102 chars)
    12. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       509: 0x132ebbc0 java.lang.String "UTF-8"
    13. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       508: 0x133eb448 byte[] (102 elements)
    14. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       507: 0x132ebbe0 byte[] (14 elements)
    15. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       506: 0x132ebc00 java.lang.String "UTF-8"
    16. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       505: 0x1307af10 java.lang.String "10.0.0.10:8080"
    17. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       504: 0x132069e0 java.lang.String "https://logs-01.... (102 chars)
    18. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       503: 0x132eb2e0 java.lang.String "UTF-8"
    19. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       502: 0x133eb4c0 byte[] (102 elements)
    20. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]   Summary:
    21. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]         1 of android.media.MediaHTTPService
    22. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]         2 of $Proxy12 (2 unique instances)
    23. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]       335 of java.lang.String (335 unique instances)
    24. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]        83 of byte[] (14 elements) (83 unique instances)
    25. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]         1 of byte[] (65 elements)
    26. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]        83 of byte[] (102 elements) (83 unique instances)
    27. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]         2 of float[] (16 elements) (2 unique instances)
    28. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]         1 of java.lang.Class
    29. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]         2 of java.lang.Class[] (1 elements) (2 unique instances)
    30. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]         1 of android.os.Message
    31. 11-30 16:18:40.960  6520  6552 F art     : art/runtime/indirect_reference_table.cc:132]         1 of android.view.Surface
    32.  
     
  6. spatial_io

    spatial_io

    Joined:
    Jul 3, 2017
    Posts:
    21
    This generally seems to be triggered by one place we call UnityWebRequest.

    We were missing calls to Dispose(), so I added them, but still seeing the same issue.

    Spacing out requests (by time) so far seems to be helping.

    But is it possible to verify that UnityWebRequest.Dispose() deletes all internal JNI references? (same for any unity-internal downloadhandler or uploadhandler implementations)
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    Are you calling UnityWebRequest many times? Based on provided log it seems to fail to connect.
    Calling Dispose() on web request is correct thing to do, but it's not related to this issue.
    Also, do you have code that interops with Java, such as AndroidJavaObject? The error you get indicates running out of Java references on native side, so the question is whether it's UnityWebRequest that leaks few or something else consuming almost all of them.