Debugger gets broken when reading big files

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Samuel Pedrajas
:warning: Old Version Published before Godot 3 was released.

Hi,

I’m experiencing a weird issue with Godot 2.1.3 running on Ubuntu 17.04. In my project, I’ve got a big JSON file of about 4000 well-indented lines. I’m reading it using this function:

func load_json(file_path):
var d = {}
var file = File.new()
file.open(file_path, file.READ)
d.parse_json(file.get_as_text())
file.close()
return d

It works well and the file is read properly. However, just after the line file.get_as_text() the debugger gets broken. I can see this error in the console:

ERROR: put_packet: Condition ' p_buffer_size + 4 > temp_buffer.size() ' is true. returned: ERR_INVALID_PARAMETER
   At: core/io/packet_peer.cpp:220.
ERROR: _notification: Condition ' cmd.get_type() != Variant::STRING ' is true.
   At: editor/script_editor_debugger.cpp:970.

After this point, if I set a breakpoint I lose the ability of stepping forward or continue the execution. The buttons just stop responding. I tried the following things:

  1. Remove keys from the JSON file to see if it stops breaking the debugger at some point. And it does. This means that the size of the file has something to do with the issue.
  2. I tried to avoid the conversion from JSON to Dictionary by creating a Dictionary object straight away in a GDScript file and pasting the content of the JSON there. The behavior is exactly the same: the debugger keeps getting broken.
  3. Since I don’t think is very convenient to use JSON files as a Data Base, I tried out this plugin: GitHub - khairul169/gdsqlite: SQLite wrapper for Godot Engine. but I just realized it doesn’t work for Android. What a pity, it looked good.

Any suggestions?

Thanks in advance,
Samuel

Looks like the implementation of this function uses a fixed-size array… not very good considering your use case, that fixed-size array is too small to temporarily contain your file. In my opinion such internal buffers should be dynamic. You should open an issue about it on Github.

Zylann | 2017-08-11 20:10

Yeah looks like a bug to me as well. Will open an issue on Github, thanks for your response!

Samuel Pedrajas | 2017-08-12 10:29