Closed letehaha closed 1 year ago
@Michaelsulistio could you take a look at this please?
Also noticed another RuntimeError. If the user doesn't respond inside the app, after like 70-90 seconds it will crash with a Timeout error from the native code. @sdlaver @Michaelsulistio
This is a full-long video to show the amount of time needed for the crash, so you can rewind it to the end to see the error
ERROR Your app just crashed. See the error below.
java.lang.RuntimeException: Could not invoke SolanaMobileWalletAdapter.invoke
com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:383)
com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
com.facebook.jni.NativeRunnable.run(Native Method)
android.os.Handler.handleCallback(Handler.java:942)
android.os.Handler.dispatchMessage(Handler.java:99)
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
android.os.Looper.loopOnce(Looper.java:201)
android.os.Looper.loop(Looper.java:288)
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
java.lang.Thread.run(Thread.java:1012)
Caused by java.lang.reflect.InvocationTargetException
java.lang.reflect.Method.invoke(Native Method)
com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
com.facebook.jni.NativeRunnable.run(Native Method)
android.os.Handler.handleCallback(Handler.java:942)
android.os.Handler.dispatchMessage(Handler.java:99)
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
android.os.Looper.loopOnce(Looper.java:201)
android.os.Looper.loop(Looper.java:288)
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
java.lang.Thread.run(Thread.java:1012)
Caused by java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException: Timed out waiting for response with id=1
com.solana.mobilewalletadapter.common.util.NotifyingCompletableFuture.get(NotifyingCompletableFuture.java:86)
com.solanamobile.mobilewalletadapter.reactnative.SolanaMobileWalletAdapterModule.invoke(SolanaMobileWalletAdapterModule.kt:124)
java.lang.reflect.Method.invoke(Native Method)
com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
com.facebook.jni.NativeRunnable.run(Native Method)
android.os.Handler.handleCallback(Handler.java:942)
android.os.Handler.dispatchMessage(Handler.java:99)
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
android.os.Looper.loopOnce(Looper.java:201)
android.os.Looper.loop(Looper.java:288)
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
java.lang.Thread.run(Thread.java:1012)
Caused by java.util.concurrent.TimeoutException: Timed out waiting for response with id=1
com.solana.mobilewalletadapter.clientlib.protocol.JsonRpc20Client$PendingRequestTimeoutTask.run(JsonRpc20Client.java:279)
java.util.TimerThread.mainLoop(Timer.java:563)
java.util.TimerThread.run(Timer.java:513)
Investigated these and have a couple of findings:
Bug #1 - Spam clicking authorize
when no wallet is available
I tried doing this on a pure React Native app and found that it does not repro. This seems to be an Expo specific issue
Bug #2 - Timeout crash on connect screen
I was able to repro this on a pure React Native app, although it just restarted the app immediately. (This might be a development behavior)
Thanks, @Michaelsulistio! That's sad about bug #1
and Expo. Maybe you have any idea if that is manageable? The problem is that, if I got it correctly, the error still comes from the lib, so even switching to bare workflow won't help in any way.
The error does come from the lib, but I have a hunch it might simply be an issue with Expo + Dev Environment. If you publish a release build of the APK and try it out, it may not crash. I can try this later, but if you get the chance test it out.
@letehaha Is there a specific reason why you would be concerned about this bug? It seems like the repro chance is pretty small, as the user needs to have no wallet installed and needs to spam click.
@Michaelsulistio sorry forgot to mention, but initially we faced that problem in APK built for prod, but not in Expo dev build. Even when I added throttle with 1000ms to prevent spamming, it was still reproducible in some way, after clicking it multiple times. For now, I increased it to 3000ms, and I personally cannot reproduce it anymore, but I still believe it's better to fix a root cause, but not to work around it. But yes for now surely no rush, cause the chance is really going to zero (I cannot imagine the case when a user installs a crypto-related app with no wallet installed, especially on Saga lol).
@letehaha Gotcha, thats really helpful to know that its not just a development behavior. Bug #2 (timeout crash) imo is more likely to reproduce so we'll look into that one first.
@Michaelsulistio this pr fixes the first issue.
@Michaelsulistio and this fixes the second issue
Thanks a lot, @Funkatronics!
Describe the bug
It's a floating bug. When calling
wallet.authorize
usingtransact
from@solana-mobile/mobile-wallet-adapter-protocol-web3js
lib, to authorize the session on the device that doesn't have wallets installed, it sometimes throws an RuntimeError.To Reproduce
Fork of
solana-mobile/expo-react-native-mwa-proof-of-concept
with a reproducable code.Since the bug is floating, it might not work from the first try, but overall the flow is next:
npm run dev:mobile
from forker repo.Expected behavior No RuntimeError, only expected one –
[SolanaMobileWalletAdapterError: Found no installed wallet that supports the mobile wallet protocol.]
.Smartphone:
Error log
Video
https://github.com/solana-mobile/mobile-wallet-adapter/assets/12257282/a7434bf0-e7fb-4c80-903c-fc8a49b82866