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 loading GDExtension dependencies on Android #88381

Conversation

m4gr3d
Copy link
Contributor

@m4gr3d m4gr3d commented Feb 16, 2024

Update the Android gdextension loading logic so that it copies any specified library dependencies alongside the gdextension shared library.

Fixes #87785

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.

Heh, just yesterday, I was just explaining to someone that the dependencies aren't used at all when loading a GDExtension, only in exporting. I guess that won't be true anymore, at least for Android. :-)

At a high-level, this looks good to me! I haven't done any testing.

core/extension/gdextension.cpp Outdated Show resolved Hide resolved
platform/android/java/lib/build.gradle Outdated Show resolved Hide resolved
@m4gr3d m4gr3d force-pushed the fix_gdextension_dependencies_load_on_android branch 3 times, most recently from 11cb180 to 0153d97 Compare February 17, 2024 00:06
@dsnopek
Copy link
Contributor

dsnopek commented Feb 23, 2024

Discussed at the GDExtension meeting, and the OS::open_dynamic_library() method is really starting to acquire a lot of arguments.

(This unrelated GDExtension PR also adds a new argument: #87117)

Perhaps we should consider having a more generic OS::open_dynamic_library() with the minimum of argument, and then another OS::open_gdextension_library() that takes lots of GDExtension-specific arguments, and the OS can do what is necessary for GDExtension? It should be OK to rework this since this method isn't exposed.

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Feb 23, 2024

Discussed at the GDExtension meeting, and the OS::open_dynamic_library() method is really starting to acquire a lot of arguments.

(This unrelated GDExtension PR also adds a new argument: #87117)

Perhaps we should consider having a more generic OS::open_dynamic_library() with the minimum of argument, and then another OS::open_gdextension_library() that takes lots of GDExtension-specific arguments, and the OS can do what is necessary for GDExtension? It should be OK to rework this since this method isn't exposed.

What about adding a gdextension specific argument which contains all the gdextension supplemental parameters and is nullptr by default for regular calls.
My concern with another method is possible confusion about what to use when since at its core a gdextension is a dynamic library.

@dsnopek
Copy link
Contributor

dsnopek commented Feb 23, 2024

I was imagining that the open_dynamic_library() would just do the low-level loading bits, and that open_gdextension_library() would probably call open_dynamic_library() (although, since both would be defined by the OS sub-class, they really could do it in whatever way made the most sense for the platform). It would only be GDExtension that would call open_gdextension_library() - any other code would call open_dynamic_library().

What about adding a gdextension specific argument which contains all the gdextension supplemental parameters and is nullptr by default for regular calls.

But, yes, that could work too! Are you imagining like a struct that has all the GDExtension info?

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Feb 23, 2024

But, yes, that could work too! Are you imagining like a struct that has all the GDExtension info?

Yeah somethink like a GDExtensionData similar to the pattern we have in other places like CustomExportData

@m4gr3d m4gr3d force-pushed the fix_gdextension_dependencies_load_on_android branch 2 times, most recently from 69b6284 to 102d62c Compare April 19, 2024 02:40
@m4gr3d m4gr3d marked this pull request as ready for review April 19, 2024 03:00
@m4gr3d m4gr3d requested review from a team as code owners April 19, 2024 03:00
@dsnopek
Copy link
Contributor

dsnopek commented Apr 19, 2024

While it isn't required to solve this now (because this is a purely internal API and we can change it at any time), I'd personally prefer if we made a struct (as discussed above) or some other strategy to reduce the number of arguments to OS::open_dynamic_library(). I don't think this is the last GDExtension-related piece of data that we're going to want to pass to this method.

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Apr 19, 2024

While it isn't required to solve this now (because this is a purely internal API and we can change it at any time), I'd personally prefer if we made a struct (as discussed above) or some other strategy to reduce the number of arguments to OS::open_dynamic_library(). I don't think this is the last GDExtension-related piece of data that we're going to want to pass to this method.

@dsnopek I've added the change into a second commit since the changes are orthogonal to each other, and to make it easier to review.

Let me know if you want me to collapse the commits together.

This is used to reduce the number of arguments to `OS::open_dynamic_library(...)`.
@m4gr3d m4gr3d force-pushed the fix_gdextension_dependencies_load_on_android branch from d553033 to 764de7f Compare April 19, 2024 14:56
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! I haven't tested it, but the code looks good to me :-)

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Apr 21, 2024

Thanks! I haven't tested it, but the code looks good to me :-)

I validated the fix in #87785 (comment)

@akien-mga akien-mga merged commit 0156bc2 into godotengine:master Apr 22, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@m4gr3d m4gr3d deleted the fix_gdextension_dependencies_load_on_android branch April 22, 2024 14:00
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.

Godot editor on android doesn't copy over dependencies whent they're located on sdcard.
3 participants