Giter Site home page Giter Site logo

Function calls made after awaiting on signal emitted from within a thread has a chance of failing abruptly without error. about godot HOT 5 OPEN

KnightNine avatar KnightNine commented on July 22, 2024 1
Function calls made after awaiting on signal emitted from within a thread has a chance of failing abruptly without error.

from godot.

Comments (5)

AThousandShips avatar AThousandShips commented on July 22, 2024

You are on a very outdated branch, please try on a supported branch and if you have your own code in your branch please remove it, bug reports are only for official code

from godot.

KnightNine avatar KnightNine commented on July 22, 2024

After further testing I've found that this issue is only present in my project,
I cannot seem to replicate it in a fresh project.

The potential causes I can think of (as someone who knows little about the core engine stuff) are:

  • Something could be interfering with threading across my Autoload scripts
  • it's due to the size of my project.
  • the import process from 3.X to 4.X has broke something in my project

(can someone with a large project and/or a project that was imported from 3.X try running a scene containing the above code?)

I synced my Godot build with the 4.3 master branch (v4.3.beta.custom_build [44ac302e3]), only preserving my modifications to astar so that my project wouldn't throw a bunch of errors due to making unsupported function calls. The result is that the issue persists.

I'll have to test removing stuff from my Autoload scripts to see if that changes anything and I'll add it here if I find anything.

from godot.

KnightNine avatar KnightNine commented on July 22, 2024

yeah, I have no idea what causes it so far, I've disabled anything that could potentially run within my Autoload scripts and it hasn't resolved it. I'll note that in 4.3 the issue doesn't seem to appear as often when the project window is in focus.
(Also I still can't replicate it in a new project so I'm leaning towards this being somehow related to the project's size)

Really want to know if anyone can replicate it or if it's just me.

from godot.

AThousandShips avatar AThousandShips commented on July 22, 2024

Pretty hard to tell, I'd say the first step is to establish if it's independent of your own code, but with the vague contexts it's pretty impossible to tell or to replicate

from godot.

KnightNine avatar KnightNine commented on July 22, 2024

I've further narrowed down the code above.

I can simplify the stability test function to:

func stability_test():
	label.text = ""
	#stability test:
	for i in range(1000):
		await reattach_to_thread()
		await get_tree().process_frame
		label.text += ", "+str(i)
		print(i)

with the issue persisting.

I also noticed that adding a delay or a print statement after the await get_tree().process_frame like so:

	await get_tree().process_frame
	OS.delay_usec(100)

fixes the issue. 🤔

This leads me to believe that this is some sort of deadlocking issue where 'await get_tree().process_frame' is being called at the exact same time as the "process_frame" signal is being emitted, the await doesn't know what to do and crashes. This would explain why it's so inconsistent.

Awaiting on a process frame from a thread isn't something that is restricted in the thread_safety_checks so maybe this possibility wasn't accounted for or seen to be possible.
Though I still can't explain why it only happens in my project...
I'm probably missing something.

from godot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.