Closed tmpfs closed 2 weeks ago
Hmm, so firstly, do you use any special things in Rust? e.g. something like android context.
In addition, try to print as many logs as possible for that automated testing, which can be quite helpful.
Also, do they provide some extra info such as full video recordings?
Hi @fzyzcjy ,
I don't load any dynamic libraries any more after the upgrade (with v1 i loaded the bindings .so), just use normal Flutter packages/libraries and nothing particularly fancy.
I just manged to reproduce this on a local device:
I/flutter ( 2345): ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
I/flutter ( 2345): The following PanicException was thrown:
I/flutter ( 2345): PanicException(android context was not initialized)
I/flutter ( 2345):
I/flutter ( 2345): When the exception was thrown, this was the stack:
I/flutter ( 2345): #0 SimpleDecoder.decode (package:flutter_rust_bridge/src/codec/base.dart:35:9)
I/flutter ( 2345): #1 SseCodec._decode (package:flutter_rust_bridge/src/codec/sse.dart:42:55)
I/flutter ( 2345): #2 SseCodec.decodeWireSyncType (package:flutter_rust_bridge/src/codec/sse.dart:37:7)
I/flutter ( 2345): #3 BaseHandler.executeSync (package:flutter_rust_bridge/src/main_components/handler.dart:34:25)
I/flutter ( 2345): #4 RustLibApiImpl.applicationNew (package:saveoursecrets/ffi/frb_generated.dart:734:20)
I/flutter ( 2345): #5 new Application (package:saveoursecrets/ffi/api/application.dart:55:28)
I/flutter ( 2345): #6 new AppModel (package:saveoursecrets/model/app.dart:250:27)
I/flutter ( 2345): #7 prepareAppProvider (package:saveoursecrets/main.dart:42:17)
I/flutter ( 2345): <asynchronous suspension>
I/flutter ( 2345): #8 main (package:saveoursecrets/main.dart:10:15)
I/flutter ( 2345): <asynchronous suspension>
I/flutter ( 2345): ════════════════════════════════════════════════════════════════════════════════════════════════════
Video recording won't help as this is when the application first boots. The stack trace is from trying to create an Application
instance on the Rust side when I prepare/boot the app.
Perhaps there is some Android specific configuration lingering from the v1 build process that is causing this, will keep looking into it.
BTW, huge thanks to you and all the other contributors for FRB v2, it is sooooo much better having the build process just be another Flutter package and the generated bindings are much easier to read and reason about. Awesome work!
I just manged to reproduce this on a local device
Great!
Btw you can setup stacktrace logging, such that we can know which exact line of Rust code causes it.
I don't load any dynamic libraries any more after the upgrade
I mean, do you use some JNI function or something that indirectly needs android?
Perhaps there is some Android specific configuration lingering from the v1 build process that is causing this, will keep looking into it.
If this may be the problem, one way is to create a brand new project by flutter_rust_bridge_codegen create
, and copy-paste your old code to it.
Huh, so this was a little convoluted to figure out but I got it working.
TL;DR needed to avoid using the app_dirs2
crate functionality on Android (which makes a JNI call) whilst main was executing.
During the upgrade I refactored from a global static Logger
to an Application
that wrapped a Logger
- the logger by default would call out to app_dirs2
to determine the application directory to store log files.
I then instantiated the Application
as an instance variable on the model final app = Application()
(which would call out over FFI and create the Logger
- making the JNI call before the android context was available). The model (and thus Application
) instantiated in main were executing before the android context is available as the MainActivity
hadn't finished launching at that point.
To work around this issue I deferred instantiating the Application
to later and avoided calling app_dirs2
methods whilst the application was booting.
Apologies for the noise @fzyzcjy and thanks again for all your work on the excellent v2 of FRB 👏
It's OK and happy to see it is solved!
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.
Describe the bug
After upgrading to v2 I get this error reported in my crashlog from automated execution against several devices in the Play Store, here is an example crash report:
This is the device info:
Steps to reproduce
Not sure how to reproduce this as it worked fine when I tested on my local device.
Logs
Expected behavior
I expected the app to run as it did with v1.82.6.
Generated binding code
No response
OS
No response
Version of
flutter_rust_bridge_codegen
v2.0.0-dev.33
Flutter info
No response
Version of
clang++
No response
Additional context
I have looked at the information in https://github.com/fzyzcjy/flutter_rust_bridge/issues/1323 and the linked PR but not sure I need to follow these steps as a vanilla app generated with v2
flutter_rust_bridge_codegen
does not seem to include that code.Any pointers much appreciated :pray: