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

IL2CPP Windows - Try block ends without any catch, finally, nor fault handler - Unity 2019.4.35 - 2019.4.37 #550

Closed
bitsandfoxes opened this issue Feb 7, 2022 · 25 comments · Fixed by getsentry/sentry-dotnet#1486 or #687

Comments

@bitsandfoxes
Copy link
Contributor

Android builds fail on Windows with IL2CPP with: Try block ends without any catch, finally, nor fault handler.
Sample in CI: https://github.com/getsentry/sentry-unity/runs/5049914009?check_suite_focus=true

Works on macOS with the same version.
Works on 2019.4.34f1
Has been reported.

@SlavomirDurej
Copy link

Please fix this as soon as possible, we can't publish our game in build < 2019.4.35f1 as we need to split binaries (supported only from build 2019.4.29f1) but theres an important bug fixed in 2019.4.35f1, so that's the only version we can actually use!

@bruno-garcia
Copy link
Member

bruno-garcia commented Feb 12, 2022

It's not really a bug in Sentry's SDK. We've reported it to Unity already.

@SlavomirDurej
Copy link

It's not rally a bug in Sentry's SDK. We've reported it to Unity already.

OK, but perhaps you can still try and add that catch clause in GlobalSessionManager::TryRecoverPersistedSession() right?

Your library is the only one that seems to trigger this issue...

@rainbowcreatures
Copy link

Hey @bruno-garcia , do you know if there's a workaround for this issue? Does Unity optimize out an empty catch/finally or whatever block(judging by the weird error)? If yes, could that be worked around until Unity comes up with a fix. We also have this issue that we're using split binaries, which have been pretty buggy(random crashes for some devices), until a fix finally implemented in 35f1. Ironically, 35f1 now causes Sentry to break. So we can't use split binary with Sentry both :(

@bruno-garcia
Copy link
Member

It's not rally a bug in Sentry's SDK. We've reported it to Unity already.

OK, but perhaps you can still try and add that catch clause in GlobalSessionManager::TryRecoverPersistedSession() right?

Your library is the only one that seems to trigger this issue...

It's likely because we're the only ones using Exception filters.
If there's no easy way around it, we might just change our code to remove the exception filters but that's a downgrade on our code and we'd like Unity to fix this instead before we take that route.

@bruno-garcia
Copy link
Member

bruno-garcia commented Feb 12, 2022

Hey @bruno-garcia , do you know if there's a workaround for this issue? Does Unity optimize out an empty catch/finally or whatever block(judging by the weird error)? If yes, could that be worked around until Unity comes up with a fix. We also have this issue that we're using split binaries, which have been pretty buggy(random crashes for some devices), until a fix finally implemented in 35f1. Ironically, 35f1 now causes Sentry to break. So we can't use split binary with Sentry both :(

If we don't hear back from Unity in the next 4 days (I'm writing this on a Saturday) we can patch our SDK to get rid of Exception filters. It's just really annoying that we need to change properly working code into a less efficient version because Unity introduced a regression on their tooling.

@SlavomirDurej
Copy link

Hey @bruno-garcia , do you know if there's a workaround for this issue? Does Unity optimize out an empty catch/finally or whatever block(judging by the weird error)? If yes, could that be worked around until Unity comes up with a fix. We also have this issue that we're using split binaries, which have been pretty buggy(random crashes for some devices), until a fix finally implemented in 35f1. Ironically, 35f1 now causes Sentry to break. So we can't use split binary with Sentry both :(

If we don't hear back from Unity in the next 4 days (I'm writing this on a Saturday) we can patch our SDK to get rid of Exception filters. It's just really annoying that we need to change properly working code into a less efficient version because Unity introduced a regression on their tooling.

Thank you Bruno, appreciate your response!

What if Unity comes back with : We (might/will) include a solution for this in the next LTS 2019.4.36f build, but without ETA? Would you be able to patch this up until they do?

@rainbowcreatures
Copy link

@bruno-garcia sounds good! I understand :( hopefully Unity can get their act together soon, but appreciate you're willingness to provide a workaround until they fix it.

@bruno-garcia
Copy link
Member

We'll ship a release with a fix today

@bruno-garcia
Copy link
Member

@SlavomirDurej
Copy link

Hi Bruno, thank you but unfortunately it still doesn't compile properly :( Just got this error when building with your latest version
IL2CPP error for method 'System.Boolean System.Text.Json.Serialization.JsonConverter1::WriteCore(System.Text.Json.Utf8JsonWriter,T&,System.Text.Json.JsonSerializerOptions,System.Text.Json.WriteStack&)' in assembly 'E:\MuseumHOGMeta\Temp\StagingArea\assets\bin\Data\Managed\Sentry.System.Text.Json.dll'
Additional information: Try block ends without any catch, finally, nor fault handler`

@bitsandfoxes
Copy link
Contributor Author

I was just running it through CI: https://github.com/getsentry/sentry-unity/runs/5197577209?check_suite_focus=true with the same issue:

IL2CPP error for method 'System.Boolean System.Text.Json.Serialization.JsonConverter1::WriteCore(System.Text.Json.Utf8JsonWriter,T&,System.Text.Json.JsonSerializerOptions,System.Text.Json.WriteStack&)' in assembly 'E:\MuseumHOGMeta\Temp\StagingArea\assets\bin\Data\Managed\Sentry.System.Text.Json.dll'
Additional information: Try block ends without any catch, finally, nor fault handler`

@bitsandfoxes bitsandfoxes reopened this Feb 15, 2022
@bruno-garcia
Copy link
Member

Well, another issue to be open with unity and this time, nothing we can do.

@SlavomirDurej
Copy link

Well, another issue to be open with unity and this time, nothing we can do.

This is really disappointing, we were quite relying on Sentry for bug tracking, but also your great Send Feedback functionality!

Is this because you can't add the catch clause to the JSON Converter class, it being a system library? Would you be able to use 3rd party json serializer instead perhaps?

@bruno-garcia
Copy link
Member

This is really disappointing, we were quite relying on Sentry for bug tracking, but also your great Send Feedback functionality!

I understand that, it's really frustraiting to us too. But another work around would require rewriting all serialization code from System.Text.Json, and since the built-in is limited in ways, we'd need to write new protocol C# classes too, to help Unity's serializer. At that point it's easier to just get back to Unity Lite SDK

This is because IL2CPP on Windows from Unity 2019.4.35f can't handle a C# exception filter.
It works on that version of Unity on a Mac. It works on Windows on a previous LTS version.
I opened a forum post here to try to get some help from Unity folks.

Hopefully this will be addressed quickly on their end so we don't need to take any drastic measures on our end (as in refactoring all protocol/serialization).

@bruno-garcia bruno-garcia changed the title Android builds fail with IL2CPP on Windows with 2019.4.35f1 IL2CPP Windows 2019.4.35f1 - Try block ends without any catch, finally, nor fault handler Feb 15, 2022
@vaind
Copy link
Collaborator

vaind commented Feb 16, 2022

Is the unity forum the best place to report errors? Maybe we should be doing that in the unity editor or hub instead? There's a "Report a bug" menu in both...

@bitsandfoxes
Copy link
Contributor Author

bitsandfoxes commented Feb 16, 2022

Is the unity forum the best place to report errors? Maybe we should be doing that in the unity editor or hub instead? There's a "Report a bug" menu in both...

I reported the bug on Feb. 2nd via the Report a bug menu and should have posted the link here aswell: https://fogbugz.unity3d.com/default.asp?1400410_ah7ukg319n7k7mn4
The forum post is just us trying to get some more visibility on the issue and to add some additional context since there is no way to append to the report.

@SlavomirDurej
Copy link

@bruno-garcia there was a LTS build released yesterday,
https://unity3d.com/unity/whats-new/2019.4.36

Looking at what's new, it doesn't look like they've fixed this issue?

@bruno-garcia
Copy link
Member

@bruno-garcia there was a LTS build released yesterday, unity3d.com/unity/whats-new/2019.4.36

Looking at what's new, it doesn't look like they've fixed this issue?

I read their changelog and couldn't spot anything that indicates this issue was addressed.
Sounds like we're using it already in CI (but on Linux only): https://github.com/getsentry/unity-docker/blob/e7c50834ccfb0aad7029158a24a8cb5719e284db/.github/workflows/ci.yml#L26-L33

The CI here/Windows steps are still on 34f which is before the bug was introduced:

unity-version: [2019.4.34f1, 2020.3.27f1, 2021.2.10f1]

We can try bumping the Windows to 36 to see if it's resolved

@vaind
Copy link
Collaborator

vaind commented Feb 24, 2022

it's still the same issue on 2019.4.36f1 (I've tried locally)

@vaind
Copy link
Collaborator

vaind commented Mar 2, 2022

I reported the bug on Feb. 2nd via the Report a bug menu and should have posted the link here aswell: https://fogbugz.unity3d.com/default.asp?1400410_ah7ukg319n7k7mn4

There was a response that they couldn't reproduce.

Anyway, the issue now seems to be related to a windows build, not android (as says in the report), so maybe a new bug report is due?

@bitsandfoxes
Copy link
Contributor Author

We're in contact with Unity, the bug report has been updated for 35 & 36, with a smaller repro and for Windows IL2CPP builds (Android & Standalone).

@bitsandfoxes
Copy link
Contributor Author

@bruno-garcia
Copy link
Member

Unity has reached out:

Thanks for reporting this issue. We found that it only happens with Unity 2020.3 and 2019.4. In newer versions other changes allow this to work properly. We've corrected the issue, and expect a fix for those versions to be released soon.

@vaind vaind changed the title IL2CPP Windows 2019.4.35f1 - Try block ends without any catch, finally, nor fault handler IL2CPP Windows 2019.4.35+ - Try block ends without any catch, finally, nor fault handler Mar 23, 2022
@vaind
Copy link
Collaborator

vaind commented Apr 11, 2022

Unity: "Fixed in: 2019.4.38f1"

Let's hope it's true

@vaind vaind changed the title IL2CPP Windows 2019.4.35+ - Try block ends without any catch, finally, nor fault handler IL2CPP Windows - Try block ends without any catch, finally, nor fault handler - Unity 2019.4.35 - 2019.4.37 Apr 14, 2022
@vaind vaind removed the Bug Something isn't working label Apr 14, 2022
@vaind vaind unpinned this issue Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
5 participants