Skip to content

Fix crash calling delegate invoke on il2cpp 29 or higher#78

Merged
Kasuromi merged 5 commits intoBepInEx:masterfrom
limoka:fix-delegate-crash
Feb 17, 2023
Merged

Fix crash calling delegate invoke on il2cpp 29 or higher#78
Kasuromi merged 5 commits intoBepInEx:masterfrom
limoka:fix-delegate-crash

Conversation

@limoka
Copy link
Copy Markdown
Contributor

@limoka limoka commented Feb 17, 2023

This PR fixes that calling delegate Invoke() method caused a crash on il2cpp version 29 or higher.

This issue is caused by a new field in the MethodInfo class called virtualMethodPointer. Now when calling delegates il2cpp uses it to determine what to call. Since Il2CppInterop was not aware of that, it's value was null thus causing the crash.

I'm not entirely sure if it's supposed to have a value of it's own though. I have checked with a type from my game and every method there had virtualMethodPointer field equal to methodPointer field.

I have tested this on Unity 2021.3.14, il2cpp 29: no crashes calling delegates or UnityEvent's

@Kasuromi Kasuromi merged commit 8b0f495 into BepInEx:master Feb 17, 2023
@limoka limoka deleted the fix-delegate-crash branch February 17, 2023 18:26
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.

2 participants