http_request returns a black colour image when app exported to android

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

Hello,

why does the code below returns the expected image when app exported to a mac but a black image when app exported to android (S9)?
(The response_code is 200 in either case.)

Thank you in advance!

func _ready():
    # Create an HTTP request node and connect its completion signal
    var http_request = HTTPRequest.new()
    add_child(http_request)
    http_request.connect("request_completed", self, "_http_request_completed")

    # Perform the HTTP request. The URL below returns a PNG image as of writing.
    var http_error = http_request.request("https://via.placeholder.com/500")
    if http_error != OK:
        print("An error occurred in the HTTP request.")

# Called when the HTTP request is completed.
func _http_request_completed(result, response_code, headers, body):
    var image = Image.new()
    var image_error = image.load_png_from_buffer(body)
    if image_error != OK:
        print("An error occurred while trying to display the image.")

    var texture = ImageTexture.new()
    texture.create_from_image(image)

    # Assign to the child TextureRect node
    $TextureRect.texture = texture

Is the Internet permission enabled in the Android export preset? (By default, an Android application isn’t allowed to access the network.)

Calinou | 2019-02-09 23:28

Yes, the internet permission is enabled. I tried Godot 3.1 with gles2 and then it worked. I would expect that S9 wouldn’t have this limitation.

gp1 | 2019-02-11 13:29