iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
600 stars 210 forks source link

Viewport.zoomToElements() causes high memory usage and eventual crash on iOS for specific model and specific elements #5931

Closed SatyakamKhadilkar closed 1 year ago

SatyakamKhadilkar commented 1 year ago

Describe the bug For a specific itwin model, while trying to zoom to specific elements (about 2200 count) using zoomToElements() API, the memory usage shoots up from around 400 Mb to 2.2 Gb and causes low memory warnings on iOS and eventual forced app closure by iOS.

To Reproduce iModel URL: https://qa-connect-imodelhubwebsite.bentley.com/Context/3fb9cf1e-4d1a-4f21-abf4-313b5f88ddac/iModel/68715f9b-c6c2-43f7-a9d7-fa94a323661f

Synchro Control URL for model: https://qa-construction.bentley.com/3fb9cf1e-4d1a-4f21-abf4-313b5f88ddac/manage-imodel/unified-viewer/68715f9b-c6c2-43f7-a9d7-fa94a323661f

Reproduce using developer's own iOS App.

  1. Build itwin sample iOS app with code to execute Viewport.zoomToElements() with the set of elementid in attached ElementIds.txt file.
  2. Open the model in above URL
  3. Execute zoomToElements() with specific ids in ElementIds.txt

Reproduce using Synchro Field App

  1. Open project AM 2023-08-01 [EUS] : [Copy] QA 6.4 MAZ 3 - D2-A22013-00-1 - DPR + Inspections
  2. More Tab -> Models -> Download Model
  3. More Tab -> Status Update (It may take a while to load the Tasks Panel)
  4. Select filter options button on top right of 'Tasks' panel.
  5. Select 'Everyone' for assignee and unselect 'This week' to remove filter for date. and press done.
  6. Select the first task 'BLDG-3 - Area A - STR - Erect Primary Stell...'
  7. Select 'Update status'

App will crash in a few seconds either at step 6 or step 7. This happens because internally the elements associated with the task are selected for zooming.

Expected behaviour iTwin web app code should not consume high memory for a zoom operation, or should try to clear memory on its own when receiving such a warning. Also, the number of elements is not too high.

Screenshots NA

Desktop (please complete the applicable information):

Additional context See attached ElementIds.txt file for selection of elements to zoom ElementIds.txt

SatyakamKhadilkar commented 1 year ago

Closing this copy after creating it in the right place. https://github.com/iTwin/itwinjs-backlog/issues/868