Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

bploeckelman
Copy link
Contributor

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.

Closes electronstudio#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 electronstudio merged commit 84e7cf8 into electronstudio:master Oct 1, 2024
@electronstudio
Copy link
Owner

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shared library can't be deleted on shutdown in Windows
2 participants