-
Notifications
You must be signed in to change notification settings - Fork 110
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
Feature: Detect when an Android device is in low power mode and throw an exception from the protocol #343
Comments
It'd be good to validate this behavior across different browsers as well, to better understand the scope of the undefined behavior we would be incorporating with this detection method. |
I am having some trouble seeing this behavior on my end. Testing on emulators and on my Pixel 3a, it seems the video can always auto play (the 'play' event always fires), regardless of the device being in low power mode. I even tried the "extreme" power mode on my Pixel and it still seems to allow auto play on the web. |
Are you on |
tested both, but now using ngrok and testing with my physical Pixel 3a, so it should effectively simulate a real website |
Also, I can test with this handy little website: https://video-dev.github.io/can-autoplay/ In all cases, autoplay continues to work regardless of the device being in low power mode or not. |
Looks like we might be able to detect when a tab becomes frozen: https://wicg.github.io/page-lifecycle/#freeze-steps This wouldn't allow us to proactively show an error in the client, but it would allow us to:
|
@sdlaver Having similar issues with the tab freezing - I am not seeing the window/document enter the The One thing I did notice: when returning to the web after successfully connecting the wallet, the web page enters the |
@sdlaver what if, when the wallet is launched from the web, we check the device low power mode on the wallet side of things, then displayed an error there? or even returned an error to the web if possible? The native app library would presumably be able to check the Android Power API, and the React Native lib could do something like this to expose the battery status to React? Its not as nice of a UX as a proactive error, but at least the user would understand why the connection wont work. |
That's what is proposed in #335, and we can certainly do that if there isn't a client-side resolution. What would be nice is for the client side to be able to detect failures to connect immediately after returning to the dApp. There are cases where a connection can take quite a long time (for e.g., if the Android disambiguation dialog is presented to the user to select their wallet app). The purpose of detecting this case would be to clean up the connection attempt from the client side once we know for certain that the connection will not succeed. The client could use this for some generic "connection failed" handling sooner than the ~90s connection timeout, which we could use to complement wallet-driven UI around reasons for the connection failure (like low-power mode). |
Ah yes, must have glossed over your proposed solution there. We could maybe us this Happy to try out any other possible solutions on the web side of things, but based on the behavior I have seen on my personal device (Pixel 3a), this is active vs passive resume state is the best I have been able to detect so far 😢 |
Problem
See #335 for the problem statement.
Proposed solution
Detect low power mode, on the client, and throw a typed exception. dApps (and/or the
@solana/wallet-adapter
can catch this exception and show a message to the user.Proposed technique
Take advantage of the fact that, in low power mode, an Android browser will refuse to autoplay a video. Presume that low power mode is on unless a shim autoplay video's
play
event fires.Reference:
https://github.com/wearemetabolism/browser-system-detect/blob/ed6ca0197c36ac8e1bff61ae707313801c202cd2/index.js#L59-L78
The text was updated successfully, but these errors were encountered: