xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
75 stars 25 forks source link

Non-blocking UI during scene loading #123

Closed stlemme closed 8 years ago

stlemme commented 9 years ago

When starting with a small scene and then programmatically adding a few hundred model tags with remote assets cause the UI to block sporadically during the loading phase of those (pure XML) assets.

This is probably caused by computationally heavy callbacks (after XHR response) blocking the UI thread for the length of several frames. This breaks the user experience when continuously interacting with the scene from the beginning.

This might be solved by a two step approach:

  1. minimize computational effort within XHR callbacks
    • add a global task queue to resource manager
    • when XHR returns, the callback just adds a new task to this queue
    • in each frame, a small number of tasks is taken from the queue and actually executed
  2. perform actual computation asynchronously using other than UI thread
    • instead of executing the tasks in each frame yourself, manage a pool of workers that
    • picks regularly a task from the queue
    • and executes each task without affecting the UI thread
csvurt commented 8 years ago

Requests are still handled on the UI thread, but with the integration of the Fetch API they're now queued and processed between frames. This should improve the interactivity of the scene during loading.