electronstudio / jaylib-ffm

Other
16 stars 2 forks source link

overwrite extracted shared lib rather than delete in shutdown hook #11

Closed bploeckelman closed 1 month ago

bploeckelman commented 2 months ago

Closes #10

Reworks how Util extracts jaylib-ffm resources from the library jar into the temp dir to workaround an AccessDeniedException when deleting extracted files on shutdown.

Deletion of the extracted files on shutdown fails due to raylib_h_1.LIBRARY_ARENA being automatically managed. This results in the raylib shared lib still being loaded in the jvm at the time the shutdown hook runs, causing the AccessDeniedException.

While we could manually manage the lifetime of the library arena, that doesn't handle cases where the jvm or the native lib crashes or otherwise shuts down unexpectedly such that the shutdown hook doesn't run, resulting in dangling temp files that never get cleaned up.

Instead of extracting resources as a randomly named file on each run, always extract the files using their actual file names into a subdirectory of the system temp directory named: 'jaylib-ffm'. This allows the extracted files to be reliably overwritten on launch rather than trying to delete the extracted files on shutdown.

electronstudio commented 1 month ago

thanks