Bug details

Adding htmlItem then closing document crashes inDesign on Mac

We are developping a plugin for inDesign and while testing a new feature on a Mac we noticed that sometimes InDesign was crashing. We managed to reproduce this bug in a very simple indesign script that make inDesign crash 100% of the time and I'm looking for a way to get around this inDesign bug.

The crash occurs when we programatically add an htmlItem to a pageItem then close the document too quicky, It's only on Mac, doing that on windows works perfectly. The crash error seems to be a memory usage problem on inDesign's side.

Here is the script code :

var document = app.activeDocument;
var sourcePageItem = document.allPageItems[0];

sourcePageItem.htmlItems.add(
document.activeLayer,
LocationOptions.AT_END,
sourcePageItem,
{
geometricBounds: sourcePageItem.geometricBounds,
htmlContent: '<b>Hello</b>',
}
);

document.close(SaveOptions.NO);

other observations :

-Doing a sourcePageItem.htmlItems[0].remove(); to remove the htmlItem after adding it doesn't change anything, so the problem comes from using the function htmlItems.add() and not having an htmlItem in the document.
-Delaying the close by using $.sleep(5000) before fix the crash, but we can't rely on it as the delay needed increase with the number of htmlItems added and it might be different from a computer to another due to performances.
-Saving the document or not doesn't change anything


I've added my clean document with just a rectangle frame, the script and the crash report on this url : https://we.tl/t-uFpX658s0o since we can't add an indeed file to the post


If there is no way to fix it, do you have an idea to get around this inDesign bug ?

1 vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

Andreï Cavoleau shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

1 comment

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Andreï Cavoleau commented  ·   ·  Flag as inappropriate

    We are developping a plugin for inDesign and while testing a new feature on a Mac we noticed that sometimes InDesign was crashing. We managed to reproduce this bug in a very simple indesign script that make inDesign crash 100% of the time and I'm looking for a way to get around this inDesign bug.

    The crash occurs when we programatically add an htmlItem to a pageItem then close the document too quicky, It's only on Mac, doing that on windows works perfectly. The crash error seems to be a memory usage problem on inDesign's side.

    Here is the script code :

    var document = app.activeDocument;
    var sourcePageItem = document.allPageItems[0];

    sourcePageItem.htmlItems.add(
    document.activeLayer,
    LocationOptions.AT_END,
    sourcePageItem,
    {
    geometricBounds: sourcePageItem.geometricBounds,
    htmlContent: '<b>Hello</b>',
    }
    );

    document.close(SaveOptions.NO);

    other observations :

    -Doing a sourcePageItem.htmlItems[0].remove(); to remove the htmlItem after adding it doesn't change anything, so the problem comes from using the function htmlItems.add() and not having an htmlItem in the document.
    -Delaying the close by using $.sleep(5000) before fix the crash, but we can't rely on it as the delay needed increase with the number of htmlItems added and it might be different from a computer to another due to performances.
    -Saving the document or not doesn't change anything


    I've added the script and my clean document with just a rectangle frame with this post.

    If there is no way to fix it, do you have an idea to get around this inDesign bug ?

Feedback and Knowledge Base