JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rate  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

User avatar
rakunavi
User
Posts: 1677
Joined: Sat Sep 11, 2021 5:04 am

JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rate

Post by rakunavi »

=== UPDATE ===================================================================
The issue reported below has been resolved in Ver 10.6.0 build 396.
I appreciate all the hard work and efforts of the support and development team.
==============================================================================


Hello all,

I sometimes use the following script so that after editing a file, I can easily revert to the pre-edited file by simply clicking on a link.

Code: Select all

this.dirty = false;
this.closeDoc(false);
app.openDoc(this.path);
If a link with this JavaScript as the action is set up in the document in advance, the document can be reverted with a single click without any dialogs or other operations. However, this JavaScript will cause the application to crash at a high rate if the display resolution is set to a high resolution such as 4K. Crashes are especially likely to occur at the following timing.

  • Immediately after opening a file from Explorer with no application running
  • Immediately after going into or leaving full-screen mode
In any case, if the application does not crash after about five times from the beginning of the operation, it tends to crash more quickly if you quit the application and start over. In actual usage scenarios, I do not use the application in this way, but it crashes at a high rate nonetheless. This is just a technique to efficiently cause crashes at the length of video allowed as the maximum attachment size in this forum.

The verification video (MP4 format) is recorded from the creation of a sample file from an empty file. After the script is executed and displayed in full screen, the application is closed normally once before crashing in order to reflect the setting values in the registry. Therefore, the actual verification does not start until around 1 minute 42 seconds. From there, the application crashes a total of seven times over a period of about 90 seconds. If each timing is shown in [mm:ss] format, they are 2:00, 2:06, 2:12, 2:22, 2:32, 2:41, and 3:07.

  • CapturedVideo.zip
  • sample.pdf
I don't know how universal the crash scenario is, but I have successfully crashed the application on at least three computers I have on hand, with varying probabilities of occurrence. It is possible that the JavaScript command is not being used properly, which may be the cause of the anomaly, but I report it just in case.

Hoping that the above information will be of some help to you.
Thank you so much for your continued support.

Best regards,
rakunavi

- PDF-XChange Editor PRO Version: 10.5.2 build 395
- OS Version: Windows 11 Pro / Home 24H2 Build 26100.3775
- PC Model: GMKtec Nucbox M7 Pro with HUION Kamvas Pro 19 / Lenovo IdeaPad C340-15IWL
You do not have the required permissions to view the files attached to this post.
Last edited by rakunavi on Tue May 06, 2025 1:42 am, edited 1 time in total.
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11036
Joined: Wed Jan 03, 2018 6:52 pm

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by Daniel - PDF-XChange »

Hello, rakunavi

Thank you for the report. I have passed this along to the Dev team for review. Hopefully they will have a solution here, or a way to fix this in the future.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11036
Joined: Wed Jan 03, 2018 6:52 pm

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by Daniel - PDF-XChange »

Hello again!

We have been unable to reproduce the crash on this end so far... could I ask that you check this directory and send us all of the "PDFXEdit.****.dmp" file which appear?
  • %LOCALAPPDATA%\CrashDumps
Since dump files are generally too large to be uploaded to the forums or sent by email, and we are asking for multiple today, please upload them directly to our useruploads server, here:
https://files.tracker-software.support/ ... ag7c2SBojn

Please let me know once the files are present.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
rakunavi
User
Posts: 1677
Joined: Sat Sep 11, 2021 5:04 am

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by rakunavi »

Hello Daniel, thank you for your investigation.

I followed your instructions and uploaded a ZIP compressed dump file (CrashDump_rakunavi.zip) to the URL you provided.
Please confirm it.

  • filename: PDFXEdit.exe.9176.dmp
    size: 458 MB (480,683,190 bytes)
    SHA256: 8485c74280734de72c605a2f2c494dbfe91631cc3b506d84c8703f93568b5006
Please give my best regards to developers.

Best regards,
rakunavi
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11036
Joined: Wed Jan 03, 2018 6:52 pm

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by Daniel - PDF-XChange »

Hello, rakunavi

Thank you, If the devs have anything to add after their investigation, I will be sure to followup. Otherwise, keep an eye out for future releases.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Mathew
User
Posts: 573
Joined: Thu Jun 19, 2014 7:30 pm

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by Mathew »

rakunavi,
If you change the script to this, does it still crash?

Code: Select all

{
this.dirty = false;
let filePath = this.path;
this.closeDoc(false);
app.openDoc(filePath);
}
I'm thinking "this" doesn't exist any more after you've closed the document, so trying to get its path may be problematic anyway. Shouldn't crash, but that the script even works in getting the path after the file is closed is surprising to me.
Mathew.
User avatar
rakunavi
User
Posts: 1677
Joined: Sat Sep 11, 2021 5:04 am

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by rakunavi »

Hello Mathew, thank you for your valuable advice.

I tried your script and unfortunately the crashes did occur. There was no particular change in the timing or frequency of the occurrence.

Best regards,
rakunavi
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
Mathew
User
Posts: 573
Joined: Thu Jun 19, 2014 7:30 pm

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by Mathew »

:(

Another approach to this script is to call the menu item "revert". You do get a confirmation dialog though (maybe a feature?)

Code: Select all

app.execMenuItem("cmd.revert",this);
I think the original script should not work based on the api:
image(1).png

By the way, your script can be made shorter by changing the parameter for this.closeDoc() to true:

Code: Select all

{
let filePath = this.path;
this.closeDoc(true);
app.openDoc(filePath);
}
You do not have the required permissions to view the files attached to this post.
User avatar
rakunavi
User
Posts: 1677
Joined: Sat Sep 11, 2021 5:04 am

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by rakunavi »

Hello Mathew, thank you for your comment.

I was aware of the Revert command, but as you guessed, I was using JavaScript to bypass the confirmation dialog.

Thank you also for presenting the relevant documentation. Given that this script does not work in Acrobat, it may be that it is trying to do something it is not supposed to do and crashing.

Additionally, thank you for the advice on shortening the script. As you pointed out, if I set the closeDoc argument to true, the confirmation dialog did not appear even without the first line "this.dirty = false;". Much appreciated, very nice.

Best regards,
rakunavi
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rate

Post by Stefan - PDF-XChange »

:)
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat  SOLVED

Post by Vasyl - PDF-XChange »

The issue with the possible crash with using the "this.closeDoc()" inside the link's JS-action - it will be fixed in the next upcoming release.
Thanks for the report.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
User avatar
rakunavi
User
Posts: 1677
Joined: Sat Sep 11, 2021 5:04 am

Re: JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rat

Post by rakunavi »

Hello Vasyl, thank you for taking the time in your busy schedule to reply.
Looking forward to the update.

Best regards,
rakunavi
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2208
Joined: Mon Jan 15, 2018 9:01 am

JavaScript "this.dirty = false; this.closeDoc(false); app.openDoc(this.path);" causes PDF-XCE to crash at a high rate

Post by Dimitar - PDF-XChange »

:)