Giter Club home page Giter Club logo

Comments (6)

ConteZero avatar ConteZero commented on May 29, 2024 1

After doing same code changes to my project now I have the same update problem with and without sudo (update_mode is set to All), probably the differences between the two modes were caused by something wrong with my code.

Luckily your suggestion solves the problem, I've added to my terminal.gd:

func _on_PTY_data_received(data):
#	parsing 'data' code
	_poll()


func _poll():
	if visible and pty and pty.has_method("get_master"): 
		pty.get_master().poll() 
		update()

Thanks for your help.

from godot-xterm.

ConteZero avatar ConteZero commented on May 29, 2024 1

There are no speed differences between update_mode Auto and All.

from godot-xterm.

lihop avatar lihop commented on May 29, 2024

@ConteZero I am not able to reproduce this issue in the test scene:

issue

However, I faced a similar issue when developing the integrated terminal EditorPlugin.

When making the integrated terminal for editor I noticed that the output would not update unless moving the cursor to focus on another panel or after some other type of gui activity (e.g. button click, scroll, cursor blink, etc.). The output from PTY is only updated by calling poll() in _process():

func _process(_delta):
if _pipe:
_pipe.poll()

In editor, _process() is not continuously called unless the editor setting 'update continuously' is set to on:

2022-08-05-113704_753x187_scrot

However, this issue affected all command output regardless of whether it had sudo or not:

issue2

My workaround was to add a timer to regularly call poll() on the underlying pipe:

# In editor _process is not called continuously unless the "Update Continuously"
# editor setting is enabled. This setting is disabled by default and uses 100%
# of one core when enabled, so best to leave it off and use a timer instead.
add_child(timer)
timer.wait_time = 0.025
timer.connect("timeout", self, "_poll")
timer.start()
func _poll():
if pty and pty.has_method("get_master"):
pty.get_master().poll()
update()

I now notice that _physics_process() is called continuously in editor, so I will consider moving the poll from _process() to _physics_process() or adding a process_mode property (like Timer has) to choose between the two.

Could you try changing func _process(_delta) in addons/godot_xterm/nodes/pty/unix/pty_unix.gd to func _physics_process(_delta), or force a regular update by calling pty.get_master().poll() with a timer?

Also, on the off chance that the issue isn't related to the PTY node, but rather the update functions of the Terminal node, you could try setting the update_mode property of Terminal to All (although this will have a slight performance penalty).

If none of these suggestions fix the problem, then I would be interested in more details about your scene setup and operating system version/environment to try and reproduce the issue and figure out why sudo commands might affect the output differently.

from godot-xterm.

lihop avatar lihop commented on May 29, 2024

After digging a bit deeper, I have found that simply adding update() at the end of terminal's write function fixes the issue I outlined above, and removes the need for a timer with the editor plugin.

@ConteZero Would you be able to undo the changes you made above and, in terminal.gd, change this code:

func write(data) -> void:
	assert(data is String or data is PoolByteArray)

	# Will be cleared when _flush() is called after VisualServer emits the "frame_pre_draw" signal.
	_buffer.push_back(data)

to this:

func write(data) -> void:
	assert(data is String or data is PoolByteArray)

	# Will be cleared when _flush() is called after VisualServer emits the "frame_pre_draw" signal.
	_buffer.push_back(data)
	update()

and let me know if that also fixes the problem?

from godot-xterm.

ConteZero avatar ConteZero commented on May 29, 2024

I did various tests using _poll(), initially seemed to have solved the problem, instead I found that sometimes some data was not written on the terminal screen.

For now your last solution seems to work well, the only drawback is that it slowdown the execution when the terminal is not visible.
I've changed it to:

func write(data) -> void:
	assert(data is String or data is PoolByteArray)

	# Will be cleared when _flush() is called after VisualServer emits the "frame_pre_draw" signal.
	_buffer.push_back(data)
	if visible:
		update()

This change avoid the slowdown but I don't know if it's right and if it can have unwanted side effects.

from godot-xterm.

lihop avatar lihop commented on May 29, 2024

For now your last solution seems to work well, the only drawback is that it slowdown the execution when the terminal is not visible.

@ConteZero Could you try the last solution but with the terminal's update_mode set to the default of Auto rather than All? I'm curious to know if it will still slowdown execution.

Otherwise, I can't think of any unwanted side effect that calling update() only if visible would have.

from godot-xterm.

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.