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

Initialize VTables for external types (#2343) #2367

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

bendk
Copy link
Contributor

@bendk bendk commented Dec 24, 2024

Fixed a tricky case from Swift: Because of it's C lineage, it doesn't have a way to run initialization code when the module is imported so instead it runs a one-time initialization function the first time a FFI call is run. This system failed when external types were used before the external module ever made an FFI call. I believe this is Swift only, but it might affect other C-like external bindings as well.

@crazytonyli thanks for the great test case for this, I shrunk it down to a mimimal test and added it to the existing fixture. When I rebase your test suite on top of this and run it with ISSUE_2343=1 cargo test --package uniffi-fixture-ext-types-sub-lib it passes. I don't think we need the all of the tests, but tell me if you think the other ones are still worth adding.

@bendk bendk requested a review from a team as a code owner December 24, 2024 15:51
@bendk bendk requested review from mhammond and removed request for a team December 24, 2024 15:51
@bendk bendk force-pushed the push-ytonspxzsszq branch 4 times, most recently from 2176b68 to c365982 Compare December 24, 2024 15:55
@bendk bendk changed the title 2343: Initialize VTables for external types Initialize VTables for external types (#2343) Dec 24, 2024
Copy link
Member

@mhammond mhammond left a comment

Choose a reason for hiding this comment

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

This looks great! I actually started looking at this last night and didn't get this far, so thanks!

Maybe change the commit message to explicitly say "Fixes #2343"?

@mhammond
Copy link
Member

does it need Python and Kotlin too?

@crazytonyli
Copy link
Contributor

The tests look good to me. I agree with @mhammond that it might be good to cover other languages. I think the same issue happens on Kotlin, too.

@bendk bendk force-pushed the push-ytonspxzsszq branch from c365982 to 76767ee Compare December 27, 2024 15:50
@bendk
Copy link
Contributor Author

bendk commented Dec 27, 2024

I didn't think Python or Kotlin needed this, but when I wrote the tests I realized that we did have the same bug in Kotlin. Added some test cases and updated the kotlin code to deal with this.

@bendk bendk force-pushed the push-ytonspxzsszq branch from 76767ee to 602b715 Compare December 27, 2024 16:14
@bendk bendk merged commit 99f3457 into mozilla:main Dec 31, 2024
5 checks passed
@bendk bendk deleted the push-ytonspxzsszq branch December 31, 2024 15:47
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.

3 participants