Skip to main content
Known Participant
October 7, 2023
Answered

InDesign freezes when performing a script from a uxp plugin

  • October 7, 2023
  • 2 replies
  • 2785 views

I ask you to help in a solution, it is not clear why the InDesign is freezing when performing the script from the UXP plugin, not at every start, but once. It can perform several functions several times well, and then it freezes on the same functions ...

After some time, such an error appears:
<system platform="Windows 11 Pro" osversion="11.0" osbuild="22621" applicationlanguage="en-us" userlanguage="ru-RU" oslanguage="en-US" ram="16104" machine="13th Gen Intel(R) Core(TM) i5-13500H" model="Intel64 Family 6 Model 186 Stepping 2" cpuCount="16" cpuType="8664" cpuFreq="3187 MHz" processorArchitecture="9"/>
<gpu>
<gpuinfo availability="Running/Full Power" adapterCompatibility="Intel Corporation" adapterRAM="1024 MB" caption="Intel(R) UHD Graphics" description="Intel(R) UHD Graphics" driverDate="20230711000000.000000-000" driverVersion="31.0.101.4575" videoModeDescription="1920 x 1080 x 4294967296 colors" pnpDeviceID="PCI&#92;VEN_8086&#38;DEV_A720&#38;SUBSYS_01571558&#38;REV_04&#92;3&#38;11583659&#38;0&#38;10" installedDisplayDrivers="&#60;&#62;,igd10iumd64.dll,igd12umd64.dll"/>
<gpuinfo availability="Running/Full Power" adapterCompatibility="NVIDIA" adapterRAM="4095 MB" caption="NVIDIA GeForce RTX 4060 Laptop GPU" description="NVIDIA GeForce RTX 4060 Laptop GPU" driverDate="20230912000000.000000-000" driverVersion="31.0.15.3742" videoModeDescription="1024 x 768 x 4294967296 colors" pnpDeviceID="PCI&#92;VEN_10DE&#38;DEV_28A0&#38;SUBSYS_01571558&#38;REV_A1&#92;4&#38;4412DE9&#38;0&#38;0008" installedDisplayDrivers="nvldumdx.dll"/>
</gpu>
<crash exception="EXCEPTION_ACCESS_VIOLATION" exceptionCode="0xc0000005" instruction="0x00007FFC117315ED">

This topic has been closed for replies.
Correct answer Anoop Valomkot

I would be very grateful for any help in solving this problem.


@AntonN This issue is tracked with bug ID-4244210 internally and is prioritized.

2 replies

Adobe Employee
October 8, 2023

@AntonN Could you please help with filing a bug and attach the script which is causing the crash? Thanks!

AntonNAuthor
Known Participant
October 8, 2023

Thanks for the answers above.

 

@Anoop Valomkot I made a plugin menu for cleat text overrides, formatting text and tables, using the example of the clear overrides menu, as a rule, in most cases the script will work correctly, but sometimes Indesign just freezes, no errors in the console, nothing. I am attaching the function code.

 

ClearOverrides.idjs // =========================================
const { app, ScriptLanguage, UndoModes } = require("indesign")
const {
  create_wrapper,
  back_to_menu,
  watch_selection,
  run_done,
  clean_err,
  set_progress,
  get_stories,
  catch_error,
} = require("./functions.js")

function zco_main() {
  const script_name = "Clear Overrides"
  const doc = app.activeDocument

  const [z_wrapper, z_main_wrapper] = create_wrapper()

  z_wrapper.innerHTML = `
    <sp-action-button quiet id="z_title" class="z_title">
      <div slot="icon" style="fill: currentColor">
          <svg viewBox="0 0 18 18" style="width: 16px; height: 16px;">
          <path class="fill" d="M6,9a.994.994,0,0,0,.2925.7045l3.9915,3.99a1,1,0,1,0,1.4355-1.386l-.0245-.0245L8.4095,9l3.286-3.285A1,1,0,0,0,10.309,4.28l-.0245.0245L6.293,8.2945A.994.994,0,0,0,6,9Z" />
          </svg>
      </div>
      ${script_name.toUpperCase()}
    </sp-action-button>
    <sp-picker placeholder = "Область обработки">
      <sp-menu id="z_picker_items" slot="options"> 
        <sp-menu-item> Entire document </sp-menu-item>
        <sp-menu-item> Selected fragment </sp-menu-item>
      </sp-menu>
    </sp-picker >
    <sp-button variant="cta" id="z_btn"> ${script_name}</sp-button>
    <sp-progressbar id="z_progress" max=100 value=0 show-value="true">
      <sp-label slot="label">Выполнение...</sp-label>
    </sp-progressbar>
    <sp-body id="z_error" class="z_error"></sp-body>`

  const z_title = document.getElementById("z_title")
  const z_picker = document.getElementById("z_picker_items")
  const z_btn = document.getElementById("z_btn")
  const z_progress = document.getElementById("z_progress")
  const z_error = document.getElementById("z_error")

  let sel = watch_selection(z_picker, z_btn)

  doc.eventListeners.add("afterSelectionChanged", () => {
    sel = watch_selection(z_picker, z_btn)
  })

  z_picker.onchange = () => {
    sel = watch_selection(z_picker, z_btn)
  }

  z_title.onclick = (e) => {
    back_to_menu(doc, z_wrapper, z_main_wrapper)
  }

  z_btn.onclick = (e) => {
    e.preventDefault()
    zco_run()
  }

  async function zco_run() {
    // run_done(z_wrapper, z_btn, script_name, true)
    z_btn.setAttribute("disabled")
    clean_err(z_error)
    set_progress(z_progress, 30, "block")

    return new Promise((resolve) => {
      setTimeout(() => {
        app.doScript(
          clear_overrides,
          ScriptLanguage.JAVASCRIPT,
          [],
          UndoModes.ENTIRE_SCRIPT,
          script_name
        )
        resolve()
      }, 750)
    }).then(() => {
      setTimeout(() => {
        // run_done(z_wrapper, z_btn, script_name, false)
        z_btn.textContent = script_name
        z_btn.removeAttribute("disabled")
        set_progress(z_progress, 0, "none")
      }, 1500)
    })
  }

  function clear_overrides() {
    console.log("Clear Overrides")
    try {
      if (z_picker.children[0].hasAttribute("selected")) {
        const stories = get_stories(doc)
        for (let s of stories) {
          if (
            s.textContainers[0].parentPage.parent != "[object MasterSpread]"
          ) {
            s.clearOverrides()
            s.footnotes.length &&
              s.footnotes.everyItem().texts.item(0).clearOverrides()
            s.tables.length &&
              s.tables
                .everyItem()
                .cells.everyItem()
                .texts.item(0)
                .clearOverrides()
          }
        }
      }

      if (z_picker.children[1].hasAttribute("selected")) {
        if (sel.words && sel.constructorName == "TextFrame") {
          const story = get_stories(sel)
          story.clearOverrides()
          story.footnotes.length &&
            story.footnotes.everyItem().texts.item(0).clearOverrides()
          story.tables.length &&
            story.tables
              .everyItem()
              .cells.everyItem()
              .texts.item(0)
              .clearOverrides()
        } else if (sel.words && sel.constructorName != "TextFrame") {
          sel.texts.item(0).clearOverrides()
          sel.footnotes.length &&
            sel.footnotes.everyItem().texts.item(0).clearOverrides()
          sel.tables.length &&
            sel.tables
              .everyItem()
              .cells.everyItem()
              .texts.item(0)
              .clearOverrides()
        }
      }

      set_progress(z_progress, 100, "block")
      z_btn.textContent = "Success"
    } catch (err) {
      catch_error(z_error, err)
    }
  }
}

module.exports = { zco_main }

// =================================================
index.js // ========================================
const { entrypoints } = require("uxp")
const { app } = require("indesign")
const { create_ui, reload_plugin } = require("./functions")
const { zvc_main } = require("./ZebraVerifyConcept.idjs")
const { zco_main } = require("./ZebraClearOverrides.idjs")
const { zft_main } = require("./ZebraFormatText.idjs")
const { ztb_main } = require("./ZebraFormatTable.idjs")
const { zgp_main } = require("./ZebraGraphPlacement.idjs")
const { zbf_main } = require("./ZebraBreakFrames.idjs")

/* 
================================ Нейминг =========================================
   *** zvc - ZebraVerifyConcept
   *** zco - ZebraClearOverrides
   *** zft - ZebraFormatText
   *** ztb - ZebraFormatTable
   *** zgp - ZebraGraphPlacement
----------------------------------------------------------------------------------
*/

entrypoints.setup({
  panels: {
    Zebra: {
      create(rootNode) {
        return new Promise((resolve) => {
          create_ui()
          app.addEventListener("afterContextChanged", reload_plugin)

          const zvc = document.getElementById("zvc")
          zvc.addEventListener("click", (e) => {
            e.preventDefault()
            zvc_main()
          })

          const zco = document.getElementById("zco")
          zco.addEventListener("click", (e) => {
            e.preventDefault()
            zco_main()
          })

          const zft = document.getElementById("zft")
          zft.addEventListener("click", (e) => {
            e.preventDefault()
            zft_main()
          })

          const ztb = document.getElementById("ztb")
          ztb.addEventListener("click", (e) => {
            e.preventDefault()
            ztb_main()
          })

          const zgp = document.getElementById("zgp")
          zgp.addEventListener("click", (e) => {
            e.preventDefault()
            zgp_main()
          })

          const zbf = document.getElementById("zbf")
          zbf.addEventListener("click", (e) => {
            e.preventDefault()
            zbf_main()
          })

          resolve()
        })
      },
      destroy(rootNode) {
        return new Promise((resolve) => {
          console.log("Destroy panel")
          resolve()
        })
      },
    },
  },
})
AntonNAuthor
Known Participant
November 21, 2023

@HARSHIKA_VERMA Hi! Thank you for your attention to this problem, it still exists unfortunately. The plugin randomly freezes when calling the app.doScript function, and after that it is no longer possible to work normally with documents in InDesign. Moreover, Indesign does not give an error, but the spinner simply spins endlessly. @Anoop Valomkot asked me to send him a spindump from a Mac, but I don’t have access to it, but I sent him a memory dump from Windows in a private message, I haven’t received a response yet. By the way, in Indesign 18.5, this random freeze happened more often, starting from version 19 it is less common, but is still present. The bug fix list on your website states that the random freezing bug when running app.doScript from a plugin is fixed in version 19, but this is not the case, unfortunately.


I would be very grateful for any help in solving this problem.

Robert at ID-Tasker
Legend
October 7, 2023

Same or differrent INDD file(s)?

 

Do you have MISSING linked files in your INDD file?

 

...

 

Have you Googled for the reason of the exception?

 

Not restricted to a specific application, the EXCEPTION_ACCESS_VIOLATION error message occurs while using almost any application on your computer. Usually, the error message pops up when the application you are trying to run tries to access a protected memory address.

 

Try to download some memory checker / stresser tool and test your memory modules - depends on the machine it could be possible to do it from BIOS - at least on DELL workstations but they use registered memory modules.

 

But first - try to reseating them in the slots - if not soldered to the motherboard...

 

Or you have a virus or bad sectors on your drive.