Problem with asynchronus rendering of macros in editor

Hello. I have some problems with the asynchronus rendering of macros in the editor, specifically with the JIRA Macro but I have seen the same issue with some other macros and widgets like image. Whenever I start editing a document in the WYSIWYG editor, the output of the macro is not rendered. It only displays an empty box or a placeholder:

When taking a look into the DOM, the document contains the following content:

<span class="macro cke_widget_element" data-macro="startmacro:jira|-|id=&quot;MyJira&quot; style=&quot;enum&quot;|-|PA-3700" data-cke-widget-data="%7B%22name%22%3A%22jira%22%2C%22parameters%22%3A%7B%22id%22%3A%7B%22name%22%3A%22id%22%2C%22value%22%3A%22My%20Jira%22%7D%2C%22style%22%3A%7B%22name%22%3A%22style%22%2C%22value%22%3A%22enum%22%7D%7D%2C%22content%22%3A%22PA-3700%22%2C%22inline%22%3Atrue%2C%22classes%22%3A%7B%22macro%22%3A1%7D%7D" data-cke-widget-upcasted="1" data-cke-widget-keep-attr="0" data-widget="xwiki-macro" data-xwiki-dom-updated="true">
	<span class="macro-placeholder">Makro:jira</span>
	<span class="xwiki-async" data-xwiki-async-id="rendering/macro/jira/xwiki%253AMain.Test.WebHome/7/http%253A%252F%252F***/request.contextpath/%25252fxwiki/request.url/http%253A%25252f%25252f***%253A8080%25252fxwiki%25252fbin%25252fedit%25252fMain%25252fTest%25252fWebHome/user/xwiki%253AXWiki.admin/wiki/xwiki/1325" data-xwiki-async-client-id="1325" data-cke-survive="true"></span>
</span>

It looks like the macro is supposed to be rendered asynchronously, but the actual result is never placed back into the document. This happens every time I edit a page containig the JIRA macro. It sometimes also happens when another person joins a realtime editing session. The document is re-rendered and then suddently they only show placeholders.

Now, whenever I insert another macro, the document content is re-rendered and then, the macro output does actually show up as expected:

I guess it is not some sort of limitation of the editor because it does work in this case. Could this be some timing problem due to the macro having to fetch external data? But if so, why does it always start to work after the next re-render of the document?

Could this be related to Loading... ?

Thx

cc @mflorea

That issue affects the in-place editing mode, but from the screenshot attached by @grimmksg , he’s using the standalone WYSIWYG edit mode, where we don’t execute the JavaScript from the edited content by default (see Loading... ). So by default, async macros, which need JavaScript to fetch the macro output asynchronously, are not “rendered” in standalone WYSIWYG edit mode, i.e. there’s no client-side rendering. The user can see only the macro rendering output done on the server-side, which can be “empty” if the server-side rendering outputs only a placeholder element with some metadata to be used client-side.

@grimmksg do you confirm you’re using the standalone WYSIWYG edit mode and not the in-place edit mode? See https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/PageEditing/#HContentEditing .

Thanks,
Marius

Yes, I am using the standalone WYSIWYG editor.

@mflorea note that for anything that rely on the standard async rendering (or anything else that check the AsyncContext), a quickfix should be to disabled async using AsyncContext#setEnabled(false) when executing WYSIWYG content.

Good point, I should disable async rendering when rendering the content for the standalone WYSIWYG editor, as long as JavaScript is disabled (default). I reported Loading... .

Note that:

  • async rendering seems to be enabled on the edit request that loads the standalone WYSIWYG editor, which is why the macro output is initially not visible in the standalone WYSIWYG editor
  • async rendering seems to be disabled on the get async requests used to reload the content after a macro is inserted or to convert the content after switching back from Source to WYSIWYG mode, even though these requests don’t have async=false.
  • async rendering seems to be enabled on the view async request used to load the content for the in-place editor

Is the async rendering enabled / disabled automatically based on the context (e.g. edit vs. get vs. view action, and whether the request is async or not)?

I’m wondering if I shouldn’t disable async rendering for the in-place editor as well, because the edited content is loaded async anyway? This means disable async rendering for WYSIWYG editor, no matter the mode (standalone or in-place), for different reasons. It would fix both:

What you are searching for is xwiki-platform/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiAction.java at master · xwiki/xwiki-platform · GitHub, I think.

1 Like