ldtk icon indicating copy to clipboard operation
ldtk copied to clipboard

LDtk keeps crashing

Open CosmicLighthouseGames opened this issue 1 month ago • 3 comments

This is the third time it's crashed today, and it keeps deleting half of my levels when it does.

Stack:

LDtk version: 1.5.3-64bits
EPERM: operation not permitted, unlink 'D:/WillT/Documents/source/Isometric-Game/Content/level_editor/0023-Level_23.ldtkl'
Error
Error: EPERM: operation not permitted, unlink 'D:/WillT/Documents/source/Isometric-Game/Content/level_editor/0023-Level_23.ldtkl'
    at Object.unlinkSync (node:fs:1780:3)
    at misc_JsTools.removeDirFiles (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:230592:15)
    at ui_ProjectSaver.initDir (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:287538:17)
    at ui_ProjectSaver.beginState (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:286750:10)
    at ui_ProjectSaver.beginNextState (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:286395:8)
    at ui_modal_Progress.onComplete (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:286719:13)
    at ui_modal_Progress.update (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:292611:10)
    at dn_Process._doMainUpdate (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:405:4)
    at dn_Process._doMainUpdate (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:432:15)
    at dn_Process._doMainUpdate (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:432:15)

Processes:

#0 App
 |--- #4 page.Editor
       |--- #5 misc.FileWatcher
       |--- #6 display.WorldRender
       |--- #7 display.LevelRender
       |--- #8 display.Camera
       |--- #9 display.Rulers[--]
       |--- #10 tool.SelectionTool[--]
       |--- #11 tool.lt.DoNothing[--]
       |--- #12 WorldTool
       |--- #13 tool.PanView[--]
       |--- #14 tool.lt.EntityTool [PAUSED][--]
       |--- #42 tool.lt.EntityTool[--]
       |--- #99 display.EntityRender
       |--- #100 display.EntityRender
       |--- #101 display.EntityRender
       |--- #102 display.EntityRender
       |--- #103 ui.ProjectSaver
       |--- #104 ui.modal.MetaProgress
       |--- #107 ui.modal.Progress

Log:

[CACHE]        Garbaging unused image LdtkIcons_32_224_16_16...
[CACHE]        Disposing cached image LdtkIcons_32_224_16_16...
[CACHE]        Garbaging unused image LdtkIcons_224_912_16_16...
[CACHE]        Disposing cached image LdtkIcons_224_912_16_16...
[CACHE]        Garbaging unused image LdtkIcons_192_592_16_16...
[CACHE]        Disposing cached image LdtkIcons_192_592_16_16...
[CACHE]        Garbaging unused image LdtkIcons_32_16_16_16...
[CACHE]        Disposing cached image LdtkIcons_32_16_16_16...
[CACHE]        Garbaging unused image LdtkIcons_96_176_16_16...
[CACHE]        Disposing cached image LdtkIcons_96_176_16_16...
[CACHE]        Garbaging unused image LdtkIcons_160_608_16_16...
[CACHE]        Disposing cached image LdtkIcons_160_608_16_16...
[CACHE]        Garbaging unused image LdtkIcons_240_976_16_16...
[CACHE]        Disposing cached image LdtkIcons_240_976_16_16...
[CACHE]        Garbaging unused image LdtkIcons_224_960_16_16...
[CACHE]        Disposing cached image LdtkIcons_224_960_16_16...
[SAVE]         => PreChecks...
[SAVE]         => BeforeSavingActions...
[EVENT]        BeforeProjectSaving
[SAVE]         => AutoLayers...
[SAVE]         => Backup...
[SAVE]         Backing up D:/WillT/Documents/source/Isometric-Game/Content to D:/WillT/Documents/source/Isometric-Game/Content/level_editor/backups/a30ec500-7820-11ed-8bd4-7b6c9f361182_2025-11-03_16-48-08...
[SAVE]           Found 41 files.
[GENERAL]      Progress created.
[RENDER]       Rendering world bg...
[GENERAL]      Progress started: : "Backup", 42 operation(s)
[SAVE]         Removing older backup: a30ec500-7820-11ed-8bd4-7b6c9f361182_2025-11-03_15-23-17
[GENERAL]      Progress completed: "Backup" (0.5s)
[SAVE]           Done!
[GENERAL]      Progress created.
[RENDER]       Rendering world bg...
[GENERAL]      Progress started: : "Preparing levels...", 40 operation(s)
[GENERAL]      Progress completed: "Preparing levels..." (0s)
[SAVE]         => SavingMainFile...
[GENERAL]      Progress created.
[RENDER]       Rendering world bg...
[GENERAL]      Progress started: : "Saving main file...", 2 operation(s)
[SAVE]           Preparing SavingData...
[SAVE]           Writing D:/WillT/Documents/source/Isometric-Game/Content/level_editor.ldtk...
[GENERAL]      Progress completed: "Saving main file..." (0s)
[SAVE]         => SavingExternLevels...
[FILE]         Emptying dir D:/WillT/Documents/source/Isometric-Game/Content/level_editor (onlyExts=[ldtkl])...
[GENERAL]      Page started: page.CrashReport()
[FILE]         Loading page template: crashReport from C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/tpl/pages/crashReport.html
[ERROR]        EPERM: operation not permitted, unlink 'D:/WillT/Documents/source/Isometric-Game/Content/level_editor/0023-Level_23.ldtkl' (Error)
[ERROR]        Error: EPERM: operation not permitted, unlink 'D:/WillT/Documents/source/Isometric-Game/Content/level_editor/0023-Level_23.ldtkl'
    at Object.unlinkSync (node:fs:1780:3)
    at misc_JsTools.removeDirFiles (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:230592:15)
    at ui_ProjectSaver.initDir (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:287538:17)
    at ui_ProjectSaver.beginState (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:286750:10)
    at ui_ProjectSaver.beginNextState (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:286395:8)
    at ui_modal_Progress.onComplete (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:286719:13)
    at ui_modal_Progress.update (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:292611:10)
    at dn_Process._doMainUpdate (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:405:4)
    at dn_Process._doMainUpdate (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:432:15)
    at dn_Process._doMainUpdate (file:///C:/Users/WillT/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:432:15)

[GENERAL]      
#0 App
 |--- #4 page.Editor
       |--- #5 misc.FileWatcher
       |--- #6 display.WorldRender
       |--- #7 display.LevelRender
       |--- #8 display.Camera
       |--- #9 display.Rulers[--]
       |--- #10 tool.SelectionTool[--]
       |--- #11 tool.lt.DoNothing[--]
       |--- #12 WorldTool
       |--- #13 tool.PanView[--]
       |--- #14 tool.lt.EntityTool [PAUSED][--]
       |--- #42 tool.lt.EntityTool[--]
       |--- #99 display.EntityRender
       |--- #100 display.EntityRender
       |--- #101 display.EntityRender
       |--- #102 display.EntityRender
       |--- #103 ui.ProjectSaver
       |--- #104 ui.modal.MetaProgress
       |--- #107 ui.modal.Progress
 |--- #108 page.CrashReport

[FILE]         Cleared all file watches

CosmicLighthouseGames avatar Nov 03 '25 23:11 CosmicLighthouseGames

Hi, First, sorry for these crashes. I STRONGLY advise you to enable Backups when working with important projects (see Project settings). It seems like the project files access is locked for some reason. Probably opened in another process/app which prevents LDtk from overwriting them. In such case, the error causes a save failure and yes, this can happen mid-save.

I will definitely make the saving process more robust in a future update, but for now, you can:

  1. Make sure you enabled Backups
  2. Save often
  3. Make sure no other app is locking your LDtk project json files and cause writing failure.

deepnight avatar Nov 04 '25 17:11 deepnight

Yeah. I already have a robust system preventing levels from getting lost. I just have a system for my game that reads levels as they're modified and refreshes them during runtime. I'll see about trying to prevent them from being read during save

CosmicLighthouseGames avatar Nov 04 '25 18:11 CosmicLighthouseGames

I also implemented hot-reloading on my side. A simple security I have is to disable hot-reloading if the game window is not focused, which is enough most of the time. Also, when you detect a file change in your game, it's probably a safe habit to delay the actual reloading by 1s or 2s to avoid start reloading while saving is in progress.

deepnight avatar Nov 05 '25 12:11 deepnight