I have a canvas called Host with many UIComponents as children, sometimes up to 1000 or 3000 items. This is fine for now, as they are not interactive.
But, I have added a ‘marker line’ (a 1 pixel wide UI Component with a colored background) to the canvas which follows the mouse movement. When this UIComponent is added to the Host canvas and moves, everything slow down to a crawl i.e. takes ages for the UIComponent to move.
What do you think could be causing this? or how to avoid?
Every time you move the mouse, you are probably causing the
measureandupdateDisplayListmethods of every one of thoseUIComponents to be called. So you may be causing those thousands of components to renegotiate their positions and dimensions with their neighbors.Without seeing your code I can’t get too specific in recommending a solution, but you might try placing a
Canvaswith a transparent background over the canvas that houses the thousands of components, matching its dimensions and location, and use that to move the marker line.