Search Unity

Any way to see runtime error of a shader on Android?

Discussion in 'Android' started by Ghopper21, Oct 16, 2017.

  1. Ghopper21

    Ghopper21

    Joined:
    Aug 24, 2012
    Posts:
    170
    I spent a day debugging by trial and error a shader, which was displaying correctly in editor and on several Android devices, but displaying incorrectly on one specific Android device. It was NOT a compile error, i.e. no pink rectangles, just displaying incorrectly, as if parts of the shader code wasn't running.

    The culprit turned out to be code in the following format:

    Code (Shader):
    1. if ( ... )
    2.     return ...
    3. else
    4.     return ...
    The problem was returning directly from within the if statement. Simply changing the code to:

    Code (Shader):
    1. fixed4 foo;
    2. if ( ... )
    3.     foo = ...
    4. else
    5.     foo = ...
    6. return foo;
    fixed the problem, i.e. creating a variable and returning after the if/else, rather than returning from within the if/else directly.

    My question is: was there any way to debug this kind of problem by seeing some error logged somewhere? (I don't see anything in the adb logcat output, but I haven't examined every one of hundreds of lines of log output.)

    Also, anyone know why this problem can occur on some Android devices but not others, and not in Editor?
     
    Last edited: Oct 16, 2017