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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

RectMask2D is very slow on Android

Discussion in '2D' started by goodguy, Oct 14, 2018.

  1. goodguy

    goodguy

    Joined:
    Jul 21, 2012
    Posts:
    18
    Hi!
    I'm building non-gaming apps using unity so I'm only using its UI and as you might have guessed in involves using masks. I've googled tons of forum threads, answers, and articles on RectMask2D, almost everywhere it's suggested as a performance optimization, but in reality (I guess it's no secret to many developers) RectMas2D is terribly slow on android devices. I worked on many projects personally, I worked in companies that also used RectMask2D in their games and it's always a cause of terrible FPS dropdowns.
    E.g. right now I'm working on a project where I've got a scroll rect with images (pretty lightweight images, about 200x150 pixels), the scrollrect contains only 3 images and the container is masked with RectMask2D. When I open a page containing this mask, the whole app starts to freeze on Android device (on any Android device, actually). The situation quickly changes if I disable the mask. It starts to work like a jet plane, everything is smooth and quick.
    Please don't tell me I'm doing something wrong and maybe it's my code that causes problems, because it's not, it works the same even without any code at all. It has been tested on many projects, devices, and unity versions, and is always the same. And the problem is on android devices only. On PC (even some midlevel one) it works smoothly.
    The same behavior is with the Mask component as well.
    By the way, even built-in unity components like Dropdown sroll slowly because of mask.
    I've created this topic to find out if someone have found/created any workarounds and can share their solution. Maybe there are some tricks with camera, layers, build settings an so on than might change this situation for the better
     
    andreyul, IEdge, TigerHix and 4 others like this.
  2. Vegeta_DTX

    Vegeta_DTX

    Joined:
    Aug 20, 2015
    Posts:
    3
    Hello there people of the Unity community :)

    I just wanted to bump this thread as I've been trying to get a solution to this problem myself so badly for the last several days without ANY success :(

    I hope I'm not going to sound overly critical and negative, but isn't Unity supposed to be this newbie-friendly content creation engine that makes people actually able to focus on making the game/software, instead of spending weeks on trying to find an esoteric workaround just to achieve the simplest things such scrolling the list of items? :(
    Unity is a glorified industry standard for video game development, and it boasts with the ease of use and fast prototyping, therefore things like these should be TRIVIAL and Unity users should be offered multiple automatic solutions to scroll rect, dropdown and other UI stuff (one for each platform).

    Again, I'm not trying to sound negative, I really like Unity and its community and so much respect everything they've done so far, I'm just trying to give a constructive criticism and believe in what I think Unity's vision was supposed to be all these years (maybe I'm wrong).

    Anyway, any help would be greatly appreciated!

    P.S. the same problem persists on all android phones I've tested this on (5 devices). As soon as RectMask2D is on, fps drops down dramatically (from 60 to 30 fps).
     
    Last edited: Nov 13, 2018
    yuliyF, justtime and goodguy like this.
  3. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    422
    I have the same for Android. RectMask2d makes it slower 2-2.5 times. BTW RectMask2d saves some draw calls, but it's nothing matters
     
  4. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    bump important thread. Any uGUI Mask with lots of child CanvasRenderers (minimap for example) create's huge fps drops. Pooling doesn't help, 'cause reparenting objects also cause stattering. Especially, mask culling make things go slower. Helps flattening Hierarchy, or moving objects out of mask, but what's point of it then? Any advices are welcome. At this moment things get us to move part of UI to SpriteRenderers, and it's tons of work, in pre-release state it's disaster.
     
  5. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
  6. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    387
  7. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    245
    Hello if you have problems with RectMask2D performance, you can try my free solution:

    https://github.com/mitay-walle/Unity3d-RectMask2DCulling

    It's children class To RectMask2D, and through reflection disables softness and culling.

    Also you can place com.unity.ugui package from Project/Library/PackageCache to Project/Packages, and add flags UseSoftness / UseCulling like here https://github.com/mitay-walle/com.mitay-walle.ugui/blob/master/Runtime/UI/Core/RectMask2D.cs

    here you can see changes I've made https://github.com/mitay-walle/com.mitay-walle.ugui/commit/3035e5e2407175c23026a6c43a55321a4c1f8770

    Also should warn you, that using ugui as embedded package force you to have no automatic updates it get with Unity3d upgrading

    Good luck
     
    GuirieSanchez likes this.