Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-20775

Live table results are not always included in the PDF export

    XMLWordPrintable

Details

    • Unknown
    • N/A
    • N/A

    Description

      This is hard to reproduce but it can happen. Suppose you have a wiki page with a live table, e.g. the page index. Open this page and export it to PDF. The PDF export is supposed to wait for the live table to load before printing the Web page to PDF. But this is not always the case.

      The live table is initialized on the dom:loaded event (well, actually xwiki:dom:loading which is triggered on dom:loaded) when it makes an XHR request to retrieve the live table results. The page-ready module should intercept this XHR request and delay the page ready until we receive the response. This page-ready module is one of the first being loaded, just after RequireJS, but since it uses RequireJS, its code is actually not executed right away (when the JavaScript code is loaded) but on the next event cycle (similar to a setTimeout(0)). As a result we have a race between dom:loaded event and the execution of page-ready module:

      • Firefox seems to trigger dom:loaded before page-ready is executed, but only when the page is loaded in a normal browser window
        • when the page is loaded in an iframe (like in the case of PDF export) the order is reversed
      • Chrome seems to execute the page-ready module before triggering dom:loaded, both on a standard window and inside an iframe

      As a result, the PDF export works for now as expected because:

      • we either use an iframe (user's browser)
      • or a head-less Chrome

      but this can change anytime, so it's very fragile. We need to make sure that page-ready module is always executed before other JavaScript code can make an XHR / fetch request.

      Attachments

        Activity

          People

            mflorea Marius Dumitru Florea
            mflorea Marius Dumitru Florea
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: