Question ... visual changes blocked while code runs?

My web app can generate a PDF report (using PDFMake) which appears in a new window that I open in front of the main app window. In some cases, it will take a long time to finish and load that PDF. I want the window to open immediately, show a progress indicator (rotating icon) and then have the PDF loaded. What happens is that the window does not open until the PDF is generated. It’s as if the visual changes are blocked while the code that generates the PDF runs.

I tried adding an onShow event handler to delay generating the PDF until after the window was visible, but the window still did not open until after quite some delay for large PDFs. For smaller PDFs, things do happen quickly.

Is there a way to block everything else so that window can open immediately, show its spinning progress indicator, and only then run the code to generate the PDF?

I added a call to webix.delay with the function being the pdf generation code, and that allowed the window to open.

Yep, this is the only way.

Due to the single-thread nature of javascript, any complex calculation will block all other changes in a browser. To allow progress or some kind animation, long time job need to be split in smaller chunks with a delay between them.