Duplicate Check
Describe the bug
When using the newly published primp 1.3.1 package (from the mobile forge) on Android, any HTTP request instantly crashes the app at the native level.
The crash occurs in the DartWorker thread with a SIGABRT and the message: android context was not initialized.
It appears that the Android JNI Context is not being passed to primp's native Rust/TLS layer by the serious_python runtime.
(I originally requested the package in #6532)
Code sample
Code
import flet as ft
import primp
def main(page: ft.Page):
def make_request(e):
try:
client = primp.Client()
# The app crashes natively on the line below before any Python exception can be caught
response = client.get("https://example.com")
page.add(ft.Text(f"Success: {response.status_code}"))
except Exception as ex:
page.add(ft.Text(f"Error: {ex}"))
page.add(ft.ElevatedButton("Test Primp HTTP Request", on_click=make_request))
ft.app(target=main)
To reproduce
- Add
primp to a Flet app and build for Android (flet build apk).
- Run the app on an Android device (tested on ARM64).
- Tap the button to trigger a
primp.Client().get() request.
- The app crashes instantly.
Expected behavior
The HTTP request succeeds without a native SIGABRT crash.
Screenshots / Videos
(Not applicable, app crashes and closes instantly)
Operating System
Linux
Operating system details
Android 16 (ARM64) / Samsung Galaxy A16
Flet version
0.85
Regression
No, it isn't
Suggestions
The Flet serious_python runtime (or the mobile forge build process for primp) needs to initialize the JNI Android Context so that the underlying Rust rustls/BoringSSL libraries can access the system certificate store.
Logs
Logs
Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 23334 (DartWorker), pid 23202 (ng.kiri.ddgs)
Abort message: 'android context was not initialized'
backtrace:
#00 pc 00000000000aa61c /apex/com.android.runtime/lib64/bionic/libc.so (abort+156)
#01 pc 00000000007caaa4 /data/data/ng.kiri.ddgs/files/flet/python_site_packages/primp/primp.abi3.so
#02 pc 00000000007aaaa8 /data/data/ng.kiri.ddgs/files/flet/python_site_packages/primp/primp.abi3.so
#03 pc 00000000007cbb84 /data/data/ng.kiri.ddgs/files/flet/python_site_packages/primp/primp.abi3.so
#04 pc 000000000056983c /data/data/ng.kiri.ddgs/files/flet/python_site_packages/primp/primp.abi3.so
#05 pc 00000000007aaaec /data/data/ng.kiri.ddgs/files/flet/python_site_packages/primp/primp.abi3.so
# ... (all subsequent frames are inside primp.abi3.so)
#30 pc 00000000002f39e8 /data/app/~~nF2otw1aVmW_t9lPNINkpQ==/ng.kiri.ddgs-A3HgMxkgd_Ef-n3KEzizeA==/lib/arm64/libpython3.12.so
#32 pc 00000000003a962c /data/app/~~nF2otw1aVmW_t9lPNINkpQ==/ng.kiri.ddgs-A3HgMxkgd_Ef-n3KEzizeA==/lib/arm64/libpython3.12.so (_PyEval_EvalFrameDefault+18220)
Additional details
Python version used on Android: 3.12.
Duplicate Check
Describe the bug
When using the newly published
primp1.3.1 package (from the mobile forge) on Android, any HTTP request instantly crashes the app at the native level.The crash occurs in the
DartWorkerthread with aSIGABRTand the message:android context was not initialized.It appears that the Android JNI Context is not being passed to
primp's native Rust/TLS layer by theserious_pythonruntime.(I originally requested the package in #6532)
Code sample
Code
To reproduce
primpto a Flet app and build for Android (flet build apk).primp.Client().get()request.Expected behavior
The HTTP request succeeds without a native SIGABRT crash.
Screenshots / Videos
(Not applicable, app crashes and closes instantly)
Operating System
Linux
Operating system details
Android 16 (ARM64) / Samsung Galaxy A16
Flet version
0.85
Regression
No, it isn't
Suggestions
The Flet
serious_pythonruntime (or the mobile forge build process forprimp) needs to initialize the JNI Android Context so that the underlying Rustrustls/BoringSSL libraries can access the system certificate store.Logs
Logs
Additional details
Python version used on Android: 3.12.