Image encoding using raw_to_base64() behaves differently on Windows and on Android

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hmilab_kevin

Hello, what I am trying to do is encode the godot camera view as a Base64 string, send over the UDP, then on another Android device decode it, and display it on Android.
Here is my simple code for godot.

# get camera view image
var img = get_viewport().get_texture().get_image()
img.resize(640, 360)

# encode to base64
var encoded = Marshalls.raw_to_base64(img.save_jpg_to_buffer())

# send to udp
if cameraPeer != null:
	var pkt = cameraPeer.get_packet()
	cameraPeer.put_packet(encoded.to_utf8_buffer())

When this scene and code is run on the desktop, the other android device is able to decode and display the image correctly.

But if I export the same scene and code onto an Android device (Meta Quest Pro), the other Android decodes and displays completely black image.

Is this something about the encoding on an Android OS? or is it something about Meta Quest?
Thanks.

I’m not aware of any particular issues here…

Have you done any comparisons of the sent and received data to see if they match (possible dropped packets?)? Also, maybe comparing the PC’s encoded data to the Android encoded data would point you in the right direction (though, the original images might not match between the two systems depending on the details).

jgodfrey | 2023-06-15 20:11

so I recorded both received b64 strings. They appear different.
The camera view is fixed and the same on both Windows and Android, and subsequent frames on each OS produce the same encoded string, but they differ between Windows and Android.

It seems they are the same for the first few lines, but then the Android one gets value like AooooAKKKKACiiig repeatedly.
They also report different encoded string length, with the Windows about 15xxx chars, Android 4xxx chars.
(The char count limit is preventing me to post the actual strings)

What might be the issue? thanks

hmilab_kevin | 2023-06-16 15:00

:bust_in_silhouette: Reply From: hmilab_kevin

so I recorded both received b64 strings. They appear different.
The camera view is fixed and the same on both Windows and Android, and subsequent frames on each OS produce the same encoded string, but they differ between Windows and Android.

It seems they are the same for the first few lines, but then the Android one gets value like AooooAKKKKACiiig repeatedly.
They also report different encoded string length, with the Windows about 15xxx chars, Android 4xxx chars.
(The char count limit is preventing me to post the actual strings)

What might be the issue? thanks