chainapsis / keplr-wallet

The most powerful wallet for the Cosmos ecosystem and the Interchain
https://www.keplr.app
Other
775 stars 463 forks source link

Brave browser - no Keplr pop-up when expected #764

Open mhagel opened 1 year ago

mhagel commented 1 year ago

Describe the bug Extension does not pop up when trying to submit a transaction in Brave browser. Experienced in multiple dapps:

To Reproduce Steps to reproduce the behavior:

  1. Go to wallet.keplr.app
  2. Click on claim reward
  3. App indicates it is waiting for response from Keplr, but keplr does not appear
  4. (infinite spinner or disabled button, with no resolution)

Expected behavior Keplr 2.0 should work on Brave

Screenshots Screenshot 2023-06-16 at 11 19 05 AM Screenshot 2023-06-16 at 11 14 18 AM

Device details (please complete the following information):

Additional context Add any other context about the problem here.

Thunnini commented 1 year ago

Does it happen in a specific environment or under a specific condition? Does restarting the web browser fix it and does it occur again under certain circumstances/condition?

mhagel commented 1 year ago

Does it happen in a specific environment or under a specific condition?

I use a Macbook Pro. I have noticed that it works fine when only using my laptop screen. But the problem occurs when Brave is open in my secondary (HP) monitor.

Does restarting the web browser fix it and does it occur again under certain circumstances/condition?

No, no change when I restart browser

Brobskie commented 1 year ago

I'm also having a lot of issues with Keplr since 2.0 upgrade.

My main problem is that Keplr simply will not connect to any dapps. I'll click on Connect wallet and then the Keplr icon and nothing happens, no pop-up.

giorgionocera commented 9 months ago

I encountered the same problem and discovered that it seems to be related to the positioning of the popup that is trying to open. Specifically, the problem occurs because the new popup tries to open in a position that is off-screen.

This problem can be replicated by using an external monitor that is set up in the operating system to be logically higher than the monitor to its right, while using a Chromium-based browser (such as Chrome or Brave) in full-screen mode.

In these circumstances, the top and left coordinates for the pop-up, which are calculated based on the dimensions of the current browser window, do not match the screen coordinates recognised by the operating system, resulting in the pop-up failing to display: Invalid value for bounds. Bounds must be at least 50% within the visible screen space.

You can see the error described in this screenshot:

Screenshot 2024-03-07 alle 12 46 27

After a check to the problem, I found that the root cause lies in the code of the openPopupWindow function, which can be found here: https://github.com/chainapsis/keplr-wallet/blob/9faf2747d16db255280484e1e9fb159dfba1457a/packages/popup/src/index.ts#L19-L30

In this section of code, the top and left parameters for the popup are determined based on the current width of the window. The intention is to display the popup (not the main window of the keplr extension, but new popups, like those for adding a new chain) near the right side of the screen. However, this calculation produces values that are not on the screen, and the popup does not open, leading to the problem encountered. A simple solution would be to always open these new windows in the upper left corner of the screen (coordinates 0,0), as this should not affect the user experience too much.

I'm working at a small PR for this.