Search Unity

After upgrade 2018.2, 'Render Texture' is not working only in mobile(iOS)

Discussion in 'General Graphics' started by eunsoossi, Jul 23, 2018.

  1. eunsoossi

    eunsoossi

    Joined:
    Apr 6, 2018
    Posts:
    8
    I have 2 problems after I got 2018.2 0f2 ver. about 'Render Texture'.

    Firstly, when I build my project for mobile(I only had tests on iOS), background image in Render Texture is broken weirdly.

    Secondly, when project starts, Camera for Render Texture is shown briefly very at the beginning.

    However, everything works fine on Unity editor.
    I'm sure this is not problem about script or graphic setting becasue when I went back to 2018.1 version everything works fine also.


    Is this bug?


    I searched for similar problem in this forum but there is no clear answer.

    Please, help. I spend whole day.....
     

    Attached Files:

  2. CR_Mike

    CR_Mike

    Joined:
    Sep 13, 2017
    Posts:
    5
    Same problem here. 2018.2 + LRP + Render Textures + Android (haven't tested iOS) = broken.

    Removing our LRP asset from Graphics Settings and manually reverting all of our materials "fixed" the issue. Anyone on the Unity side able to comment on potential fix/workaround? Thanks!
     
  3. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
    "Broken" is not enough information to say something useful.
    At least a screenshot or a description of how it's broken could help a lot :)
    Submitting a bugreport would be the best option, of course.
     
  4. CR_Mike

    CR_Mike

    Joined:
    Sep 13, 2017
    Posts:
    5
    Sorry, figured it was already a known issue as I can't seem to get them to work even in a fresh LRP project on Android.

    Environment:
    2018.2.0f2
    SDK 28.0.1
    JDK 1.8.0_181
    LRP 2.0.5-preview

    Results:
    • Fire HD 10: main project, when rendering a render texture to raw image causes entire screen to go black (but game continues to run in background and remains interactable). Works fine on PC.
    • Galaxy Tab A: main project, rendering a render texture to raw image causes rendering to "freeze" (but game continues to run in background and remains interactable). Works fine on PC.
    • Galaxy Tab A: test project, rendering a render texture to raw image just didn't show up at all (but no black screen or freeze!). Works fine on PC.
    Some of the things tested:
    • Modifying LRP asset settings (removing HDR, etc) - Failed
    • Using on-disk Render Textures (vs generated at runtime) - Failed
    • Testing different on-disk Render Texture settings - Failed
    • LRP 3.0.0-preview - Failed
    • Applying LRP material to Raw Image that render texture is bound to - Failed
    • Generate Shader Includes - Failed (UnauthorizedAccessException on GeometryUtils.cs.hlsl)
    • Actually NOT rendering camera to render texture but otherwise leaving everything exaclty the same - Success
    • Removing LRP asset from Graphics settings and hand-converting all materials back to standard shader - Success
    NOTE: providing screenshots of the above won't help as they would be of a black or frozen screen :)

    NOTE 2: OnPostRender doesn't seem to work (not called at all) in LRP projects. Tested in fresh LRP project.

    NOTE 3: On Fire HD, when trying to render the render texture, lines similar to the following appear in the log (can post actual log later but all devices are currently unavailable):
    • unexpected struct parameter 'unity_Builtins2Array[1].unity_SHCArray'
     

    Attached Files:

  5. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
    What's the RT format and what are tha camera settings?
    Does this camera have post effects?
     
  6. eunsoossi

    eunsoossi

    Joined:
    Apr 6, 2018
    Posts:
    8

    My project has gone back to previous version of Unity 2018.1, so I can't share anymore.
    But I made a similar situation in version 2018.2 and it happens again.

    This is the Unity project file for test. It's very simple project.
    https://drive.google.com/file/d/1AqZwdnjfmCiYP7BSXGi2nM67Y-oE6ZVB/view?usp=sharing

    Sorry, I am kind of newbie on Unity and I'm not a professional developer, so I don't know which part of code or bugreport should I submit.

    I think there would be not error message because it works fine on Unity editor. It happens only on mobile.


    I attached image also.
    The grey square is the broken part. It shoud be clean.


    Thank you for helping!
     

    Attached Files:

  7. CR_Mike

    CR_Mike

    Joined:
    Sep 13, 2017
    Posts:
    5
    Standard (default) render texture settings in our test case. I've attached a screenshot just in case. When created at runtime, I specified the same settings in code.

    Camera settings are also attached. Nope, no post effects!

    Notes:
    • Camera culling mask is set to only the content we want to be rendered in that camera (3 layers total)
    • The Field Camera script is simply a registration callback system for OnPostRender calls (which don't work in LRP).
    • The camera target texture is set to a render texture made at runtime (as we've always done it), not the one on disk, which is why it shows no name in the field.
    It's nothing fancy. Works without LRP, doesn't work with.

    Thanks for the reply! Any suggestions would be greatly appreciated...
     

    Attached Files:

  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
    https://unity3d.com/unity/qa/bug-reporting
    This is the preferred way for us to work with bugs.
    You can submit a bug report with the simple test project you've created.

    Yes, doesn't look like anything should be broken there. Can you try looking into what's happening using RenderDoc?
    Or just submit a bugreport :)
     
  9. matheus-cardoso

    matheus-cardoso

    Joined:
    Aug 10, 2017
    Posts:
    7
    We're facing the same problem. When I try to open the project in an Android device I got this error in the logs:

    Code (CSharp):
    1.                   CRASH  E  signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr b72e8850
    2.                          E  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    3.                          E  Build fingerprint: 'motorola/titan_retbr_ds/titan_umtsds:6.0/MPB24.65-34-3/3:user/release-keys'
    4.                          E  Revision: 'p400'
    5.                          E  pid: 17207, tid: 17259, name: UnityMain  >>> com.mycompany.app <<<
    6.                          E      r0 00000001  r1 b72e8770  r2 00000003  r3 b9344100
    7.                          E      r4 3f800000  r5 b92e8770  r6 00000000  r7 00000000
    8.                          E      r8 9fb271e4  r9 00000000  sl b9a61c6c  fp 9fb26c88
    9.                          E      ip 9fc81308  sp 9fb26b58  lr a02a18a8  pc a05479d8  cpsr b3f06c90
    10.                          E  backtrace:
    11.                          E      #00  pc 00a1f9d8  /data/app/com.mycompany.app-1/lib/arm/libunity.so
    12.                          E      #01  pc 007798a4  /data/app/com.mycompany.app-1/lib/arm/libunity.so
    13.                          E      #02  pc 0074b280  /data/app/com.mycompany.app-1/lib/arm/libunity.so
    14.                          E      #03  pc 00007a08   ( (wrapper managed-to-native) UnityEngine.Texture:set_anisoLevel (UnityEngine.Texture,int) {0xba678d28} + 0x50 (0x915449b8 0x91544a68) [0x9da5af00 - Unity Root Domain]+31240)
    15. '(.]...
    16.                         E      9fb27274 ba67dee0 0000000f 0000000f 0000001e  ..g.............
    17.                         E      9fb27284 ba6f4570 ba67dee0 a0d4c748 ba67def0  pEo...g.H.....g.
    18.                         E      9fb27294 a0d4c700 ba67dee0 a0d4c700 00000227  ......g.....'...
    19.                          E      9fb272a4 a0b4603d 00000046 9ffa8d90 0000000c  =`..F...........
    20.                          E      9fb272b4 00001c20 ba67def0 9ffa8d1c 00001c20   .....g..... ...
    21.                          E  memory near sl:
    22.                          E      b9a61c4c 00000079 a0cfebd8 00001238 17500026  y.......8...&.P.
    23.                          E      b9a61c5c 00000000 ffffffff 00000000 00000000  ................
    24.                          E      b9a61c6c 00000031 00000000 ba4bb840 ba4bb500  1.......@.K...K.
    25.                          E      b9a61c7c ba4bb380 00000007 ba4bb500 00000003  ..K.......K.....
    26.                          E      b9a61c8c 0000000b 00008008 00000000 00000058  ............X...
    27.                          E      b9a61c9c 00000013 b9a648c8 a13ff424 00000000  .....H..$.?.....
    28.                          E      b9a61cac 0000001b b9a648c8 b9a648c8 b991dbf0  .....H...H......
    29.                          E      b9a61cbc 00000000 00000018 00000043 00000081  ........C.......
    30.                          E      b9a61ccc 06005ca4 b9a5fa80 b9a61a40 9a9f9289  .\......@.......
    31.                          E      b9a61cdc 7fff9000 00000000 00000000 00000000  ................
    32.                          E      b9a61cec b9a5cea0 b9a5fa58 00000000 b927b140  ....X.......@.'.
    33.                         E      b9a61cfc 00000000 00000040 0000002b 00000015  ....@...+.......
    34.                         E      b9a61d0c 44000d0c 0288080e 0e44018e 0a980238  ...D......D.8...
    35.                         E      b9a61d1c 44080e44 0000000b 00000000 00000028  D..D........(...
    36.                         E      b9a61d2c 00000023 99839478 ffff0001 06400000  #...x.........@.
    37.                         E      b9a61d3c b9a5c050 b6d37f08 b6d37f08 00000020  P........... ...
    38.                         E  memory near fp:
    39.                         E      9fb26c68 00000000 92b19e60 9fb271e4 00000000  ....`....q......
    40.                         E      9fb26c78 b9a61c6c 9fb26c88 9fb26c88 9154432c  l....l...l..,CT.
    41.                         E      9fb26c88 00000000 00000000 00000000 9da5af00  ................
    42.                         E      9fb26c98 9fb26cbc 99866b98 9fb26cbc 9939ef84  .l...k...l....9.
    43.                         E      9fb26ca8 9fb26ef8 b9eaf1d0 9fb26ef8 ba256f28  .n.......n..(o%.
    44.                         E      9fb26cb8 9157fc50 00000500 000002d0 9fb271e4  P.W..........q..
    45.                         E      9fb26cc8 00000000 9fb271e4 9fb26cd8 9df44d74  .....q...l..tM..
    46.                         E      9fb26cd8 00000000 00000000 00000000 00000000  ................
    47.                         E      9fb26ce8 9fb26cfc 00000000 92b19e60 9fb270a0  .l......`....p..
    48.                         E      9fb26cf8 9fb271e4 915442c0 9fb271e4 9fb271e4  .q...BT..q...q..
    49.                         E      9fb26d08 9fb26e8c 993a0cd8 9fb26ef8 00000000  .n....:..n......
    50.                         E      9fb26d18 9fb271e4 9fb270a0 92b19e60 b9d963a0  .q...p..`....c..
    51.                         E      9fb26d28 00000000 00000002 00000000 00000000  ................
    52.                         E      9fb26d38 00000000 00000000 00000000 00000000  ................
    53.                         E      9fb26d48 00000000 00000000 00000000 00000000  ................
    54.                         E      9fb26d58 00000000 00000000 00000000 00000000  ................
    55.                         E  memory near ip:
    56.                         E      9fc812e8 13510000 0a000001 e5910024 e12fff1e  ..Q.....$...../.
    57.                         E      9fc812f8 e92d4800 eb22971b e1a0e00f ea22ad30  .H-...".....0.".
    58.                         E      9fc81308 e3500000 15902008 13520000 0a000001  ..P.. ....R.....
    59.                         E      9fc81318 e1a00002 ea17ee82 e92d4800 eb229711  .........H-...".
    60.                         E      9fc81328 e1a0e00f ea22ad26 e3500000 15901008  ....&."...P.....
    61.                         E      9fc81338 13510000 0a000001 e5910028 e12fff1e  ..Q.....(...../.
    62.                         E      9fc81348 e92d4800 eb229707 e1a0e00f ea22ad1c  .H-...".......".
    63.                         E      9fc81358 e3500000 15902008 13520000 0a000001  ..P.. ....R.....
    64.                         E      9fc81368 e1a00002 ea17ee75 e92d4800 eb2296fd  ....u....H-...".
    65.                         E      9fc81378 e1a0e00f ea22ad12 e92d4010 e24dd008  ......"..@-...M.
    66.                         E      9fc81388 e3500000 e1a04001 15901008 13510000  ..P..@........Q.
    67.                         E      9fc81398 0a000007 e5910000 e5902068 e1a0000d  ........h ......
    68.                         E      9fc813a8 e12fff32 e89d0003 e8840003 e28dd008  2./.............
    69.                         E      9fc813b8 e8bd8010 eb2296eb e1a0e00f ea22ad00  ......".......".
    70.                         E      9fc813c8 e3500000 15901008 13510000 0a000001  ..P.......Q.....
    71.                         E      9fc813d8 e1a00001 ea17ca87 e92d4800 eb2296e1  .........H-...".
    72.                         E  memory near sp:
    73.                         E      9fb26b38 00000000 00000000 00000000 00000000  ................
    74.                         E      9fb26b48 ba6eb280 9fb26bb8 9fb26bb4 994c28e0  ..n..k...k...(L.
    75.                         E      9fb26b58 ba6eb2a0 3f800000 00000000 00000000  ..n....?........
    76.                         E      9fb26b68 9fb26c88 a02a18a8 ba6eb280 ba6eb2a0  .l....*...n...n.
    77.                         E      9fb26b78 00000000 a0273284 9fb26b94 9da61f20  .....2''motorola/titan_retbr_ds/titan_umtsds:6.0/MPB24.65-34-3/3:user/release-keys'
    78.                          E  Revision: 'p400'
    79.                          E  pid: 17207, tid: 17259, name: UnityMain  >>> com.mycompany.app <<<
    80.                          E      r0 00000001  r1 b72e8770  r2 00000003  r3 b9344100
    81.                          E      r4 3f800000  r5 b92e8770  r6 00000000  r7 00000000
    82.                          E      r8 9fb271e4  r9 00000000  sl b9a61c6c  fp 9fb26c88
    83.                          E      ip 9fc81308  sp 9fb26b58  lr a02a18a8  pc a05479d8  cpsr b3f06c90
    84.                          E      at libunity.00a1f9d8(Native Method)
    85.                          E      at libunity.007798a4(Native Method)
    86.                          E      at libunity.0074b280(Native Method)
    87.                          E      at Unknown.00007a08(Unknown Source)
    When I comment the RenderTexture code it works:

    Code (CSharp):
    1. //    private RenderTexture _renderTexture;
    2.     private Camera _camera;
    3.  
    4.     void Start()
    5.     {
    6. //        _renderTexture = new RenderTexture( Screen.width, Screen.height, 0);
    7. //        _renderTexture.name = "TransitionTexture";
    8. //        _renderTexture.anisoLevel = 0;
    9. //        _renderTexture.wrapMode = TextureWrapMode.Clamp;
    10. //        _renderTexture.format = RenderTextureFormat.ARGB32;
    11. //        _renderTexture.filterMode = FilterMode.Bilinear;
    12.      
    13. //        _texture.mainTexture = _renderTexture;
    14.         _texture.width = Mathf.CeilToInt((float)_baseHeight * ((float)Screen.width/Screen.height));
    15.         _texture.height = _baseHeight;
    16.     }
    17.  
    18.     public void StartRecording()
    19.     {
    20.         _camera = Camera.main;
    21. //        _camera.targetTexture = _renderTexture;
    22.         _texture.gameObject.SetActive (true);
    23.     }
     
    Last edited: Jul 25, 2018
  10. matheus-cardoso

    matheus-cardoso

    Joined:
    Aug 10, 2017
    Posts:
    7
    I've discovered that setting the following code is causing the crash:

    _renderTexture.anisoLevel = 0;


    Maybe it's what caused the crash on Android? Are you also trying to change the renderTexture settings?
     
  11. eunsoossi

    eunsoossi

    Joined:
    Apr 6, 2018
    Posts:
    8
    In my case, it happened on iOS(I didn't check Android).

    I tried to change all settings that I know on Unity edtior(not on code) but it took time too long for each testing because I had to build for mobile for each testing.

    I submitted bug report to Unity. I'm going to tell you when they answer.
     
  12. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
  13. matheus-cardoso

    matheus-cardoso

    Joined:
    Aug 10, 2017
    Posts:
    7
    We're able to solve this problem enabling the 32 Bits Display Buffer in Player Settings
     
  14. CR_Mike

    CR_Mike

    Joined:
    Sep 13, 2017
    Posts:
    5
    Unfortunately our problem remains exactly as before: attempt to use a render target in the UI (with a raw image) causes the entire screen to go black. I'm on 2018.2.4f1 and have tried the suggestions above.

    Anyone have any other suggestions? Being tied to standard rendering with no shader graph is cramping our style :)

    Will write up an official bug later this week.
     
    ina likes this.
  15. Jde

    Jde

    Joined:
    Oct 2, 2011
    Posts:
    137
    I'm getting a similar issue. Since updating to Unity 2018.2.4 my bespoke depth render is black when running on Android, but looks fine in editor and on iOS (it was fine on Android using 2017.3). I'm rendering to a temporary depth render texture in OnPreCull using shader replacement.

    Curiously, I captured some frames using the Graphics API Debugger (https://google.github.io/gapid/about/), and the captured frame shows a correct depth render even though the device shows it as black...!? Like this...

    upload_2018-9-11_19-31-36.png

    However, using the Unity Frame Debugger connected to the device shows it as black! It's very confusing.

    Any ideas?
     
  16. Jde

    Jde

    Joined:
    Oct 2, 2011
    Posts:
    137
    Some more info on this... The built in _CameraDepthTexture render (created when a camera's depthTextureMode is set to DepthTextureMode.Depth) shows up fine.

    It's the same format as my bespoke one, has the same resolution, uses the same shader replacement pass, and happens at the same time in the render stack (before the main render).
     
  17. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
    @Jde are you using camera.settargetbuffers?
     
  18. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
  19. Jde

    Jde

    Joined:
    Oct 2, 2011
    Posts:
    137
    I'm not using that, no. I just tried setting the buffers but no change. It does sound similar to that bug though.

    Something else which may be relevant... When I select one of the realtime shadow depth render draws in the Frame Debugger (under Shadows.RenderJobDir), it shows a broken, empty, dark grey square image. But when I select a subsequent opaque draw, the shadow shows up correctly on the object, so it was clearly rendered properly! Hard to say whether that's an issue with the Frame Debugger or not.
     
  20. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
    So, I just found out the root cause for the issue I linked earlier. It's related to rendering to a custom depth texture in general, so it will likely fix your issue.
     
    Tom8i likes this.
  21. Jde

    Jde

    Joined:
    Oct 2, 2011
    Posts:
    137
    Great! Which version would the fix go into? And is there a workaround in the meantime?
     
    Tom8i likes this.
  22. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
    Not sure, which version exactly, but expect it to be fixed in 2018.2.
     
  23. Jde

    Jde

    Joined:
    Oct 2, 2011
    Posts:
    137
    We're on 2018.2.4. I'll keep an eye on the bug for the release version, but let me know if you discover a workaround for 2018.2.4 (in case we can't update to the fixed version for whatever reason). Thanks.
     
  24. eunsoossi

    eunsoossi

    Joined:
    Apr 6, 2018
    Posts:
    8

    In Ver 2018.2, this issue still happened....

    It happens only on iOS. Android OK.


    I submitted bug report, and I got email from Unity almost 2 month ago they were trying to fix it.

    But I have still this issue...

    Is it impossible to upgrade to 2018.2????
     
  25. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    841
    Current issue is render texture works fine on a regular game object, but does not work on a raw image on iOS
    (everything is fine in editor)

    using latest unity
     
  26. Rienhl

    Rienhl

    Joined:
    Nov 14, 2013
    Posts:
    41
    So I was having the same problem and stumbled upon this revived thread.

    Can anybody confirm if this is fixed on 2019 for iOS and Android and if there are any patches for 2018?
     
  27. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
    This ended up being fixed in 2018.3.0b6.
    If there is still something not working as expected, please submit a bug report.
     
  28. dcarnelutti

    dcarnelutti

    Joined:
    Jul 30, 2018
    Posts:
    3
    im still facing the same issue in 2018.3.10f1 I see a white square in iOs but everything works fine in Unity Editor.
     
    Fimiam likes this.
  29. Fimiam

    Fimiam

    Joined:
    Oct 24, 2016
    Posts:
    7
    Actually, a solution is pretty simple. The problem is about OGLES 2.0 that doesn't support depth textures and you can read about it in this article https://docs.unity3d.com/Manual/SL-DepthTextures.html
    So you just need to switch your project to 3.0 version by unckecking a checkbox "Auto Graphics API" in the Player Settings > Other Settings and then choose compatible API level.
     
  30. Vaibhav_77

    Vaibhav_77

    Joined:
    Feb 5, 2019
    Posts:
    2
    In Which version it is fixed?
     
  31. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,037
     
  32. RandyLarson

    RandyLarson

    Joined:
    Nov 20, 2017
    Posts:
    2
    FWIW --

    I also noticed this problem on Android / MacOS with a `2019.1.2f1` build of my project. This project started out as a `2017.X.X` project. The bug we are talking about was working in this version. This project was upgraded through the `2018.3.x` versions reported as introducing the problem.

    I created a new `2019.1.2f1` project and tried to repro the problem in isolation. I could not.

    I noticed:
    • The `RenderTexture` created with the new `2019.1.2f1` project had a different property collection than a render texture created with the older, upgraded, project.
    So:
    • I created a new `RenderTexture in the new `2019.1.2.f1` project and dragged that to my original project.
    • I adjusted the camera in the old project to use this copied render texture.
    The texture now renders on Android as expected.
     
  33. JJunior

    JJunior

    Joined:
    May 22, 2019
    Posts:
    12
    Hey guys, I was having a similar problem on Unity 2019.3.0a3, Android platform, and by changing from Vulkan to OpenGL my video works like a charm. I tested with the Video Player component using a Raw Image and a Render Texture, and also worked rendering on Camera Near Plane (in this case no Render Texture involved).

    Hope this can help u guys.
     
  34. zmalderh

    zmalderh

    Joined:
    Jan 3, 2020
    Posts:
    2
    For anyone still trying to fix this issue....I have a new solution which has worked for me and nothing else would. If none of the above comments are helping you, this may work for you as well. I was able to get the video to play on the far or near plane camera - but nothing else would work with video. so If you run into this issue you can try this: Setup another camera inside of your main camera. Have the video show in the far plane and stretch the image to fit the view as you like. Then you can position that camera within the view of your main camera and BOOOM!

    Really hope this can help someone
     
  35. zmalderh

    zmalderh

    Joined:
    Jan 3, 2020
    Posts:
    2
    Edit: If you want the video to play in a specified spot in the scene, you could set that camera to point in the direct spot you want and that will work