-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async JSI calls with ThreadPool and callback #29
Conversation
Its compiling here, but crashing on the JNI Adapter: 03-11 17:59:31.242 13476 13476 F DEBUG : Abort message: 'JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0x12f6fbc8 I will do some tests in this branch too. :) |
@ospfranco Finally I think I manage to get it working on Android! But I think that we will need to rework functions like sequel_execute. This funcions receive and produce jsi::Object values, and in order to do that, they will need to do their works inside the JavaScript thread. When this functions do their work on the thread spawed by the pool causes erros. Tomorrow I will rework the loadSQLFile function, because this feature can do the heavy work without touch jsi::Runtime. It will only need to use this object in order to produce the result status, and for this object its way more simple. |
@ospfranco I belive that we will need to implement another function to use instead of "sequel_execute" in async operations. In this way, we can execute sqlite operations in any thread without the need to synchronization for read or build jsi::Value objets. We can translate the parameters that users sent to us as arguments in the JavaScript caller thread, and then execute the operation in a task thread and use invokeAsync only to parse the results and translate it back to jsi objects to pass on the callback. What do you think? |
I take it you ran into the same issues I did. Which is namely, it looks like one cannot create jsi::Values from another thread and then return them in the callback. It's a bummer. Indeed, the only way to move forward seems to me to refactor all the JSI code from the sqlite adapter code, my C++ is a bit too weak though, I started doing it and ran into many issues. I will continue through the day, but in any case, I do not want to have two different implementations (one depending on the JSI runtime object and one returning pure C++ data), I much rather do everything in C++ and convert the data at the end. |
I got some of the dynamic types working, @EduFrazao maybe you can continue during the week, otherwise, I will continue working on it next weekend |
Hi @ospfranco. I will check it right now. Thank you very mutch. I'm already using the async LoadSQLFile method and its working so nice :). |
ehm, yeah, I started refactoring the JSI code out of the sequel adapter, I will also do a major renaming of classes and stuff. but instead of using enums and structs I'm using C++ 17 |
Yeah, code looks cleaner. I will do some tests with your approach and compare with "classical" structs and try to migrate my whole App do fully use async executeSql commands :). |
- Method exported to its own file
- Exported to this own file - Created the async version of this feature
Hi @ospfranco . |
@ospfranco I tested this changes with my current application, using sync and async methods, with and without hermes, and no problems so far. On IOS I can only test on the emulator. |
Thanks Edu, I still want to get rid of the duplicated execute_query methods and have only one |
@EduFrazao I removed the execute_sequel method that contained JSI code, would you mind testing it again on your methods and making sure everything is working, it would also be good if you can add example/test methods in the |
Very nice. I wil run my tests and try to test on IOS too. |
Tested on Android 11 Emulator and physical device Tested methods: executeSql, asyncExecuteSql No issues observed. |
@EduFrazao great, thanks. Would you mind taking care of the last review comment, trying to reduce the number of gradle dependencies? |
Sure, I will do some tests tonight. |
Done. PR #34 opened. |
No description provided.