Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

IL2CPP Seems To Be Stripping Parts Of 2DRenderer

Discussion in 'Editor & General Support' started by DrHerringbone, Jul 17, 2021.

  1. DrHerringbone

    DrHerringbone

    Joined:
    Jan 3, 2021
    Posts:
    13
    Unity 2D project, using 2D URP, with bloom effect:

    Answer:

    Building the project with all target ABIs selected fixed the
    Missing Method Exception
    error. For whatever reason, having all the ABI's selected as targets disabled code stripping entirely and stopped the problem. I don't know why my link.xml file failed to due this. 99% sure it was usor arrer.

    The bloom issues were totally unrelated but happened to coincide with the
    Missing Method Exception
    error due to the target hardware not being capable of displaying HDR color. Below are screen caps of my render and pipeline asset settings:

    Renderer:
    Unity Renderer ScreenShot.png

    Pipeline img 1&2:

    Unity Pipeline 1 ScreenShot.png
    Unity Pipeline 2 ScreenShot.png

    Problem:
    I am going to try to be as detailed as possible here, include as much code as I think is necessary, and give as many of my novice and likely erroneous thoughts as possible. I am very sorry if it seems like I'm blathering (I probably am...)

    I have a project with a relatively simple c++ native library that, until the past few days I have been building for android 8.1 Arm7. It has been going great. Until my business partner and I decided to upgrade the "proprietary" hardware on which the app will ship to Arm64 :(. I switched to IL2CPP got my native libraries exported for any android kernel format and assumed everything would go great... WRONG!

    A very nice bloom effect that had worked flawlessly until the switch was suddenly and totally gone, I also began getting an error from Android SDK Logcat. The error seems to have to do with, what I can only guess is IL2CPP stripping methods (that I needed *WRONG they were totally unrelated to any of my code, why the methods were being called, I still don't know, my project includes zero reflection probles*) from either the 2D Renderer (I am much less convinced this is true as of now *IT WAS THE RENDERER the camera was supposedly calling the method i was just dumb at reading error logs and my project had a camera in it lol*), or the camera sourcecode. The error reads as follows and seems to happen every update:

    Code (CSharp):
    1. 2021-01-01 18:24:49.753 14242-14287/com.drherringbone E/Unity: MissingMethodException: UnityEngine.Experimental.Rendering.BuiltinRuntimeReflectionSystem::BuiltinUpdate()
    2.       at UnityEngine.Experimental.Rendering.BuiltinRuntimeReflectionSystem.TickRealtimeProbes () [0x00001] in /Users/bokken/buildslave/unity/build/Runtime/Export/Camera/BuiltinRuntimeReflectionSystem.bindings.cs:11
    3.       at UnityEngine.Experimental.Rendering.ScriptableRuntimeReflectionSystemWrapper.Internal_ScriptableRuntimeReflectionSystemWrapper_TickRealtimeProbes (System.Boolean& result) [0x00010] in /Users/bokken/buildslave/unity/build/Runtime/Export/Camera/ScriptableRuntimeReflectionSystemWrapper.cs:13
    WRONG: This initially sent me down the path of IL2CPP scripting limitations having to do with AOT. See the following snippet from the Unity Manual: https://docs.unity3d.com/Manual/ScriptingRestrictions.html
    But... I don't think that's it. I think the inclusion of the word reflection is an unfortunate coincidence, maybe, probably, hopefully??

    What I CURRENTLY think is happening is that IL2CPP is stripping the required methods

    TickRealtimeProbes ()
    from the camera (nope it was the renderer... I think lol) source.

    So I did some digging and decided:

    Make a link.xml file!.. I did but I'm not sure I'm doing it right :oops:. I previously thought that IL2CPP was stripping necessary methods from the Experimental Renderer so that is what is currently being preserved. It reads as follows:
    Code (CSharp):
    1. <linker>
    2.   <!--
    3.   Preserve types and members in an assembly
    4.   -->
    5.   <assembly fullname="UnityEngine">
    6.     <type fullname="UnityEngine.Experimental.Rendering.ScriptableRuntimeReflectionSystem" preserve="all"/>
    7.  
    8.   </assembly>
    9. </linker>
    10.  
    I tried the following fixes before getting everything right I will underline the steps that I think you should follow to efficiently trouble shoot similar problems:
    • Blindly mucking around with quality and HDR settings :oops: (you will become increasingly less blind with time)
    • Setting Auto Detect Graphics API on, off (LEAVE THIS ON)
    • Try disabling the OpenGLE requirements
    • disabling vulcan, disabling GLE2, disabling GLE3 (This CAN help in some cases, not mine)
    • setting fire to my computer, praying to the dark lord, praying to god, praying to Tom Cruise and his voodoo witchcraft...
    • Reimporting the project.
    • Removing and Reinstalling URP
    • Trashing my RenderPipeline asset/data
    • Trashing my PostProcessing Data
    • Considering a different line of work
    • Up, Down, and all around grading of Unity much to my chagrin.
    So here I am, my first forum post. Once again I am sorry for any gross incompetence. I'd say that I'm a "compitunt" coder, but I'm totally self taught and learning by making mistakes but this one has me solidly stumped.

    Look kindly upon me, your humble and loyal? servant.
     
    Last edited: Sep 20, 2021
  2. DrHerringbone

    DrHerringbone

    Joined:
    Jan 3, 2021
    Posts:
    13
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    You should report a bug on this. The error doesn't seem like it's coming from your code.
     
    DrHerringbone likes this.
  4. DrHerringbone

    DrHerringbone

    Joined:
    Jan 3, 2021
    Posts:
    13
    I will!
     
  5. DrHerringbone

    DrHerringbone

    Joined:
    Jan 3, 2021
    Posts:
    13
    Big update: The problem seems to be stemming from my custom c++ native library that allows unity to talk to AAudio. I made a test project with bloom and it worked fine (thought it is still dimmer than it should be on both emulators and real hardware... but not the editor...)

    When I removed the script that talks to the dll, problem gone.

    Why? I am guessing that AAudio and unity's builtInUdate function are clashing somehow because my dll works as it should.
     
  6. DrHerringbone

    DrHerringbone

    Joined:
    Jan 3, 2021
    Posts:
    13
    Final Update and Answer!

    The problem persisted after recreating the app from total scratch, including the dll (this turned out for the best because the app is way more stable and runs significantly faster because I was able to create the app with all the knowledge gained from the first time and I had a very clear idea of what the app would do and how I wanted to do it).

    In addition the audio was now EXTREMELY distorted and off flat (440hz was playing back as 250hz of pure fuzz).

    In a desperate attempt at getting some sort of reference I built the app for an x86 emulator (something that had previously failed due to me not knowing enough about ABIs) and it worked flawlessly...

    I was now convinced that the cheap chinese hardware that the app is required to run on was too bootleg for the app to run and I started to gear up to write my own custom android rom.

    Answer:
    In a desperate attempt I tried one more build with every ABI selected in unity and it worked flawlessly.

    Logcat gave one clue as to why:
    Code (CSharp):
    1. I/Unity: Built from '2021.2/staging' branch, Version '2021.2.0b12 (8137c0cefaf0)', Build type 'Development', Scripting Backend 'il2cpp', CPU 'arm64-v8a', Stripping 'Disabled'
    note
    Stripping 'Disabled'
    I think that building the code for all ABIs including chrome based ABIs forced IL2CPP to strip zero code and eliminated my problems.

    As previously stated I have tried Link.xml files to no benefit, there's decent documentation on them but there's also a chance that I was misreading the error messages or not using the correct assembly names. The assembly names are a little ambiguous but I got the assembly names I used from VSC's assembly browser.

    I hope this hack workaround helps someone because this problem has put me back close to 4 months now.