-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Disable main_thread_id assertion for Android debug build #780
Conversation
Thank you! Could you add a comment re. why it's commented-out? To prevent this from happening again. Please then squash commits to 1 🙂 |
The assertion was revived on 82a14f68 I’m not sure about the current status of Linux hot-reloading. |
What about expanding the Followed by an explanation why on Android this doesn't work, that would be really valuable. |
12e423b
to
df4a5d3
Compare
I have added checking Android to the existing cfg condition |
df4a5d3
to
adb70d0
Compare
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-780 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a problem with this change, which is explained in the assert message:
attempted to access binding from different thread than main thread; this is UB
The whole rest of the library relies on access being single-threaded -- if we just disable the check, we might really run into UB.
Does anyone familiar with Android know why access happens from a different thread in Android? And if that's fine, or what the best practices are to deal with this?
Maybe one of the people involved in #470, e.g. @scripturial @moberer @MeganSpencer @Jim-Bar @walksanatora?
// CHECK Need to check on more platforms. | ||
// Currently, a runtime panic occurs on Android. | ||
if cfg!(all(debug_assertions, not(target_os = "android"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably mean TODO:
instead of CHECK
?
I don’t feel qualified to comment on Godot threading issues but I do have a suspicion regarding the cause of the problem I had. I didn’t realise callbacks from http requests in Godot could be on a separate thread. (I assume this is the case.) so when crossing into rust it’s possible that you end up in rust on a different thread (without realising). I think this can then cause updates to data or callbacks into Godot to occasionally crash. The work around for me has to call back from rust into Godot using ‘call_deferred’ I’m not sure if it is the design of call_deferred to force “cross to main thread” but since I started doing this I’ve not had any android crashes. The Swift plugin developer that made one of my plugins does the same “hack” where you call back into a gdscript function then invoke call_deferred which makes it rather messy. It may be that this patch actually would have told me what I did wrong straight away and helped me solve the problem quicker. So maybe it’s a win? (On hot reloading specifically, I use Mac for development so I can’t comment on hot reloading specifically) |
@scripturial Thanks for the info!
Could you link me to that plugin and/or issue they had?
Do you have any suspicion why this might happen on Android but not on other platforms? Or maybe @jeyum2, can you be more specific about the circumstances which caused panic in your case? Can you come up with a minimal, complete example that reproduces the problem? |
I've just merged #794 which addressed a similar issue, with Wasm. Could you rebase the PR onto latest Also, would be great to hear about the panic circumstances 🙂
Thank you! |
When running a debug build of an empty project, a panic occurs immediately during the initialization process.
|
adb70d0
to
de0f6c0
Compare
I have confirmed that the same panic occurs on Android with the master branch where #794 has been merged. |
This code block causes a runtime panic during initializing in Android debug builds Signed-off-by: Jan Haller <[email protected]>
de0f6c0
to
11b0ab7
Compare
While I'm not a fan of not getting to the root of things and just silencing the problem, it doesn't help anyone if Android setup is just totally broken, either. I added a comment in the code, hopefully someone with more expertise can investigate this in the future. |
This assertion block was previously commented out and reactivated without a clear reason in git history
It causes a runtime panic in debug builds for Android
If this assertion is required, please implement logic that also considers Android