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

Fix reload of GDExtension libraries in framework package on macOS #95143

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

TV4Fun
Copy link
Contributor

@TV4Fun TV4Fun commented Aug 4, 2024

GDExtension::open_library has a check in it to see if the library was loaded from a temp file, and if it was to restore the original name as that is the one we actually care about. This check is breaking extension reloading on Mac when the library path is to a framework folder, as the file inside the framework will not generally be the same name as the folder.

This check also shouldn't be necessary even on Windows, which is the only platform that uses generate_temp_files, since disposal of the created temp file is handled within OS_Windows::open_dynamic_library, and GDExtension::open_library (which is the only function to call open_dynamic_library with a p_data argument) only cares about the original library file path and has to do extra work to remove the name of the temp file. Instead, I have removed that check and set OS_Windows::open_dynamic_library to return the name of the original file and not the name of the copy.

This fixes GDExtension reloading on macOS. I do not have a Windows machine available to test that it still works properly on Windows, so someone should check that before merging this.

@TV4Fun TV4Fun requested review from a team as code owners August 4, 2024 17:42
@Chaosus Chaosus added this to the 4.3 milestone Aug 4, 2024
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This looks good to me. I tested on Windows and it seems to be working just fine: creation and clean-up of the temporary copy looks good, and a quick test of reload worked fine. I also tested on Linux, just to ensure there wasn't any regression there.

It's probably too late to get this into Godot 4.3-stable, but this is something we should definitely cherry-pick for Godot 4.3.1-stable.

@dsnopek dsnopek added platform:windows cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release labels Aug 7, 2024
@dsnopek dsnopek modified the milestones: 4.3, 4.4 Aug 7, 2024
@dsnopek
Copy link
Contributor

dsnopek commented Aug 7, 2024

Thanks for making the change I suggested!

However, you'll need to squash this down to one commit, per Godot's development workflow:

https://docs.godotengine.org/en/latest/contributing/workflow/pr_workflow.html#the-interactive-rebase

`GDExtension::open_library` has a check in it to see if the library was loaded
from a temp file, and if it was to restore the original name as that is the one
we actually care about. This check is breaking extension reloading on Mac when
the library path is to a framework folder, as the file inside the framework
will not generally be the same name as the folder.

This check also shouldn't be necessary even on Windows, which is the only
platform that uses `generate_temp_files`, since disposal of the created temp
file is handled within `OS_Windows::open_dynamic_library`, and
`GDExtension::open_library` (which is the only function to call
`open_dynamic_library` with a `p_data` argument) only cares about the original
library file path and has to do extra work to remove the name of the temp file.
Instead, I have removed that check and set `OS_Windows::open_dynamic_library`
to return the name of the original file and not the name of the copy.

This fixes GDExtension reloading on macOS. I do not have a Windows machine
available to test that it still works properly on Windows, so someone should
check that before merging this.
@TV4Fun TV4Fun force-pushed the fix_non_windows_library_load branch from 2ffe454 to f44d6a2 Compare August 8, 2024 14:32
@TV4Fun
Copy link
Contributor Author

TV4Fun commented Aug 8, 2024

@dsnopek fixed now.

@dsnopek
Copy link
Contributor

dsnopek commented Aug 8, 2024

Thanks!

@akien-mga akien-mga changed the title Fix reload of GDExtension libraries in framework package on macos Fix reload of GDExtension libraries in framework package on macOS Aug 16, 2024
@akien-mga akien-mga merged commit a8bbb09 into godotengine:master Aug 16, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@TV4Fun TV4Fun deleted the fix_non_windows_library_load branch August 17, 2024 00:34
@akien-mga
Copy link
Member

Cherry-picked for 4.3.1.

@akien-mga akien-mga removed the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants