Open Myran opened 2 years ago
Make sure your link for image is useful. delete "&text=test" My test code on Android is working well. Just check your code or the export setting,When exporting to Android, make sure to enable the INTERNET permission in the Android export
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 error = http_request.request("https://via.placeholder.com/512")
if error != OK:
push_error("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 error = image.load_png_from_buffer(body)
if error != OK:
push_error("Couldn't load the image.")
var texture = ImageTexture.new()
texture.create_from_image(image)
# Display the image in a TextureRect node.
var texture_rect = TextureRect.new()
add_child(texture_rect)
texture_rect.texture = texture
Make sure your link for image is useful. delete "&text=test" My test code on Android is working well. Just check your code or the export setting,When exporting to Android, make sure to enable the INTERNET permission in the Android export
The image request works using editor and on iOS and I get the crash with any image only on android. The request works with regular json target on android and INTERNET permission is enabled.
This example crashes the same way for me. I will try to get ahold of another android phone to rule out the device
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 error = http_request.request("https://via.placeholder.com/512") if error != OK: push_error("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 error = image.load_png_from_buffer(body) if error != OK: push_error("Couldn't load the image.") var texture = ImageTexture.new() texture.create_from_image(image) # Display the image in a TextureRect node. var texture_rect = TextureRect.new() add_child(texture_rect) texture_rect.texture = texture
I'm not sure if it's related to your Android SDK version or others. you can try to export other Android applications and have a test to run normally without http request node.
---Original--- From: @.> Date: Wed, Mar 30, 2022 04:41 AM To: @.>; Cc: "吾也君( Atem @.**@.>; Subject: Re: [godotengine/godot] HTTPRequest crash on android when requesting image (Issue #59672)
Make sure your link for image is useful. delete "&text=test" My test code on Android is working well. Just check your code or the export setting,When exporting to Android, make sure to enable the INTERNET permission in the Android export
The image request works using editor and on iOS and I get the crash with any image only on android. The request works with regular json target on android and INTERNET permission is enabled.
This example crashes the same way for me. I will try to get ahold of another android phone to rule out the device
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 error = http_request.request("https://via.placeholder.com/512") if error != OK: push_error("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 error = image.load_png_from_buffer(body) if error != OK: push_error("Couldn't load the image.") var texture = ImageTexture.new() texture.create_from_image(image) # Display the image in a TextureRect node. var texture_rect = TextureRect.new() add_child(texture_rect) texture_rect.texture = texture
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>
Also crashes the same way on a ASUS Chromebook C302CA
Found the issue
I am building the android export using the following optimization as shown in the documentation:
scons platform=android target=release_debug android_arch=armv7 --jobs=$(sysctl -n hw.logicalcpu) module_bmp_enabled=no module_bullet_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_etc_enabled=no module_gdnative_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_mbedtls_enabled=no module_mobile_vr_enabled=no module_opus_enabled=no module_pvr_enabled=no module_recast_enabled=no module_regex_enabled=no module_squish_enabled=no module_tga_enabled=no module_thekla_unwrap_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_vorbis_enabled=no module_webm_enabled=no module_websocket_enabled=no disable_advanced_gui=no disable_3d=yes optimize=size use_lto=yes
The crash goes away once I build with all modules so one of them is required however Its not obvious for me which one is required for images trough HTTPRequest. Is it possible to list dependencies on each module somehow?
Hm, try enabling them one by one? (Starting with tinyexr, etc, websockets, mbedtls and dds, so things related to either the net or images. I think Bullet and CSG can be safely ruled out as not being the cause)
Found it:
module_mbedtls_enabled=yes
is required to not crash when requesting an image trought HTTPRequest. I had accidentaly disabled all optimizations for iOS which made it work on the ipad and that made me rule out the optimizations early.
I am not familiar with mbedtls so I dont know if this is a bug or correct behaviour
It's normal that HTTPS request wouldn't work without mbedTLS, which is the module that provides support for SSL/TLS (the "S" in HTTPS).
But it shouldn't crash, instead it should throw an error, so that's still something that needs to be fixed in the engine.
Godot version
3.4.4 stable - 419e713a29f20bd3351a54d1e6c4c5af7ef4b253
System information
Galaxy S9, SM-G960F
Issue description
Attempting to retrieve an image using HTTPRequest works fine in editor (MacOS) and on iOS however it crashes on android device. Tried with different images with no success
Retrieving a json as in documentation example works on perfectly on android, in editor and on iOS.
Steps to reproduce
Run test function on android device
Minimal reproduction project
No response