You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are trying to optimize our binary size, and in particular seem to be having an issue with setting opt-level="z" in the cargo profile. Everything builds fine, but at runtime we get this error:
We don't seem to have this problem on Kotlin with the same profile configuration.
We also have strip = true enabled which we already know works. We tried removing this and removing other optimization flags, but it didn't help the error. Interestingly, the address in the error doesn't seem to change either with the build tweaks we've tried.
Any ideas on how to debug this further? I wouldn't think opt-level="z" would affect more than performance. Thinking it's probably a bug in UniFFI, or an incompatibility with opt-level="z" that should be documented.
fileprivatefunc uniffiRustCallAsync<F, T>(
rustFutureFunc:()->UInt64,
pollFunc:(UInt64,@escapingUniffiRustFutureContinuationCallback,UInt64)->(),
completeFunc:(UInt64,UnsafeMutablePointer<RustCallStatus>)->F,
freeFunc:(UInt64)->(),
liftFunc:(F)throws->T,
errorHandler:((RustBuffer)throws->Swift.Error)?)asyncthrows->T{
// Make sure to call the ensure init function since future creation doesn't have a
// RustCallStatus param, so doesn't use makeRustCall()
uniffiEnsureUniffiYttriumInitialized()letrustFuture=rustFutureFunc()defer{freeFunc(rustFuture)}varpollResult:Int8;
repeat{
pollResult =awaitwithUnsafeContinuation{pollFunc( // ================== Error here ==================
rustFuture,
uniffiFutureContinuationCallback,
uniffiContinuationHandleMap.insert(obj: $0))}}while pollResult != UNIFFI_RUST_FUTURE_POLL_READY
returntryliftFunc(makeRustCall({completeFunc(rustFuture, $0)},
errorHandler: errorHandler
))}
The text was updated successfully, but these errors were encountered:
We ran into the exact same problem. For us it happened regardless optimization settings on both iOS (swift) and Android (kotlin). After investigating we found the cause. It was an enormous allocation of memory on stack (1MB) in rust code: let mut buf = [0; SIZE];
We resolved it by moving the allocation onto heap (using Vec). Maybe double-check your code doesn't do something similar (stack overflow, ...).
We are trying to optimize our binary size, and in particular seem to be having an issue with setting
opt-level="z"
in the cargo profile. Everything builds fine, but at runtime we get this error:We don't seem to have this problem on Kotlin with the same profile configuration.
We also have
strip = true
enabled which we already know works. We tried removing this and removing other optimization flags, but it didn't help the error. Interestingly, theaddress
in the error doesn't seem to change either with the build tweaks we've tried.Any ideas on how to debug this further? I wouldn't think
opt-level="z"
would affect more than performance. Thinking it's probably a bug in UniFFI, or an incompatibility withopt-level="z"
that should be documented.The text was updated successfully, but these errors were encountered: