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

Writing bool values to PoolByteArray works in debug but not release exports #48999

Closed
HaSa1002 opened this issue May 23, 2021 · 6 comments
Closed

Comments

@HaSa1002
Copy link
Contributor

Godot version:
3.3.1

OS/device including version:
Windows 10, 19042.928

Issue description:
You can't write to PoolVectorArrays in release exports.
Debug (Editor/Export):

======= BOOL =======
Start:		00000
Expected:	00100
Got:		00100

Release Export:

======= BOOL =======
Start:		00000
Expected:	00100
Got:		00000

with code:

print("======= BOOL =======")
print("Start:\t\t", pba_str(byte_data))
byte_data[2] = true
print("Expected:\t00100\nGot:\t\t", pba_str(byte_data))

Steps to reproduce:

  1. Open MRP
  2. Run in Editor
  3. Export
  4. Uncheck "Export with Debug"
  5. Run exported build

Minimal reproduction project:
PoolVector.zip
The project includes test for all PoolVector types.

@Calinou Calinou changed the title PoolByteArray is read only in release exports PoolByteArray is read-only in release exports May 23, 2021
@Calinou
Copy link
Member

Calinou commented May 23, 2021

In Godot 3.x, Pool*Arrays are passed by value instead of reference. Maybe that explains it? Either way, the behavior should not differ between debug and release.

In Godot 4.0, Packed*Arrays are passed by reference until they're passed to a low-level server, in which case they are passed by value.

@HaSa1002
Copy link
Contributor Author

More context than in the snippet above:

extends Node
var byte_data := PoolByteArray([false, false, false, false, false])

func _ready():
	print("======= BOOL =======")
	print("Start:\t\t", pba_str(byte_data))
	byte_data[2] = true
	print("Expected:\t00100\nGot:\t\t", pba_str(byte_data))

I access the Vector by value there.

@akien-mga
Copy link
Member

akien-mga commented May 23, 2021

That's a weird bug, but it seems to be related to your use of boolean values. It works fine with ints:

var byte_data := PoolByteArray([0, 1, 2, 3, 4])

func _ready():
        print("before")
        for b in byte_data: print(b)
        byte_data[2] = 6
        print("after")
        for b in byte_data: print(b)
before
0
1
2
3
4
after
0
1
6
3
4

It works fine if you cast the bool to int explicitly (byte_data[2] = int(true)).

@akien-mga akien-mga changed the title PoolByteArray is read-only in release exports Writing bool values to PoolByteArray works in debug but not release exports May 23, 2021
@HaSa1002
Copy link
Contributor Author

Okay. Good to know. That seems to be an GDScript bug?
I can workaround my Input.is_action_pressed with int(...) then.

@Xrayez
Copy link
Contributor

Xrayez commented May 23, 2021

That seems to be an GDScript bug?

Yeah, looks like GDScript issue to me, there were many debug vs. release differences in GDScript implementation in the past.

@akien-mga
Copy link
Member

Fixed by #57851.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants