lightning-browser-extension icon indicating copy to clipboard operation
lightning-browser-extension copied to clipboard

Extension prompts are not being opened on multi-monitor setups

Open aaroncarlucci opened this issue 1 year ago • 13 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

I am using primal.net as a NOSTR client. Originally installed Alby browser extension in Brave brower on Apple machine OSX. Brave synced the extension to Brave on my other computer on Ubuntu 23.10, running Wayland and Nvidia 535.154.05. When I try to zap on primal.net from that computer, it doesn't work and I get the JS console errors in the screenshot.

Most importantly, when I check the Discovered Sites settings on the Linux machine, primal.net isn't registered. However, it registered and functioning fine on OSX. I am unable to get Alby to register the site, or to make the zap. In fact, I get the same error when trying to zap on snort.social from that machine.

I've tried uninstalling and reinstalling the extension, as well as creating completely new accounts, but those doesn't help. Shared account is connected to my own CLN node using commando rune. Nostr keys are imported and set correctly on both environments.

After some investigation, I'm thinking that Brave is having an issue drawing the modals needed to zap or register the site. Could be a browser-specific issue related to #2378 ?

I've been in contact over email with Moritz from customer support. Let me know if I can provide more information to help debug.

Screenshots [optional]

Screenshot from 2024-02-08 13-26-38

Screenshot from 2024-02-07 13-21-35

Steps To Reproduce

  • Setup Alby on Brave on OSX, link to external CLN node and import NOSTR keys (no master key generation).
  • Allow extension synchronization to sync to Brave on Ubuntu 23.10
  • Navigate to primal.net
  • Observe no ask to connect the site
  • Try to zap a note, observe amount increments and then decrements, no modal to confirm zap is displayed, observe errors in screenshot in console logs
  • Observe primal.net not listed in connected sites in Alby settings
  • Naviate to snort.social
  • Try to zap a note, observe error "Error: Invalid value for bounds. Bounds must be at least 50% within visible screen space." displayed in snort modal after confirming to zap with LNPAY.

Expected behavior

primal.net should be listed under connected sites on the Linux environment and zaps should work.

Alby information

Alby 3.6.0 Installed through Chrome Web store and synced between devices -- also reinstalled Wallet: CLN node over Tor using commando runes

Device information

OS: Linux Ubuntu 23.10 Browser Brave

  • 1.62.162 Chromium: 121.0.6167.164 (Official Build) (64-bit)
  • Revision c18c9cc62d2b4376a5ada5b98b673dfc7994f20d
  • JavaScript V8 12.1.285.28

Additional context

In my research, I also found this repository:

https://github.com/getAlby/alby-installer-linux/blob/master/brave.sh

Should I be using this specially in order to install Alby for Brave?

Are you working on this?

None

aaroncarlucci avatar Feb 08 '24 12:02 aaroncarlucci

Thanks for this detailed error report and your analysis. I just tried using Brave on Ubuntu and that seemed to work fine on my machine. 😟

Since this problem seems to be related to positioning the prompt: Are you using a multi-monitor setup, virtual desktops or anything like that?

Would you be willing to run a development version of the extension where I add some more logging to find out what exactly is going wrong here?

reneaaron avatar Feb 08 '24 17:02 reneaaron

Yes, I'm using a multi-monitor setup. Laptop with 4 external monitors, three with DisplayPort daisy-chained and one over HDMI.

Yes, I will consider running a development version. Is it available as a public Git branch on this repository so I can check it out and verify the debugging code differences for myself? Can't be too safe...

aaroncarlucci avatar Feb 08 '24 19:02 aaroncarlucci

@acarlton Great to hear that. Definitely. You'll see the exact difference, sure - probably we'd just add some more log statements to figure out what is going wrong exactly. I'll let you know as soon as it's ready for a testrun :raised_hands:

reneaaron avatar Feb 12 '24 14:02 reneaaron

@acarlton I just created a draft PR with some more logging:

https://github.com/getAlby/lightning-browser-extension/pull/3048

You should be able to download the extension build over here when the build is finished: https://github.com/getAlby/lightning-browser-extension/actions/runs/7928935027?pr=3048

A guide on how to install those builds can be found here: https://guides.getalby.com/user-guide/v/alby-account-and-browser-extension/alby-browser-extension/debugging/using-nightly-builds

After you have installed the development build try to reproduce the problem and share what you see in the development console:

https://guides.getalby.com/user-guide/v/alby-account-and-browser-extension/alby-browser-extension/debugging/google-chrome

Feel free to reach out if you need any assistance and thanks for your help!

reneaaron avatar Feb 16 '24 10:02 reneaaron

@reneaaron I installed the extension by checking out the PR branch, building it locally and importing the local build "Load unpacked" into Brave. Also disabled my VPN. Setup my exterior node into what seems to be a new wallet with the new extension.

When load primal.net or Snort, I'm not seeing the debug statements at all in the console. It's the same behavior as originally reported. My first glance at the code seems like there is an issue enabling WebLN. The Alby extension icon is not green when I navigate to primal.net, and the there are no entries in "Connected sites" in the extension dashboard.

Attached full console stacktrace. Screenshot from 2024-02-16 11-58-02

edit: I should probably add that after this stacktrace, an additional entry in the console log reads Enable was rejected ignoring further webln calls.

aaroncarlucci avatar Feb 16 '24 11:02 aaroncarlucci

@reneaaron Doh! I debugged this myself for a while before realizing the screenshot I provided earlier as for the frontend console. Here is a screenshot of the service worker console. Hope it helps! Let me know if I can provide more information.

Screenshot from 2024-02-16 14-47-53

aaroncarlucci avatar Feb 16 '24 13:02 aaroncarlucci

@acarlton Thanks for debugging this further. :raised_hands:

The coordinates in the log outputs seem to be correct. I suspect there is some error in how your browser calculates the visible area that might be related to your fancy display setup. :thinking:

Do you see the same problem when you e.g. only use your notebook display or one additional display via HDMI?

reneaaron avatar Feb 19 '24 13:02 reneaaron

@reneaaron I've confirmed when I unplug my fancy setup, the modal works fine on the native laptop monitor. I may want to pursue this upstream. So...

  • Can you confirm -- are the coordinates in your debug statements relative to the current display?
  • Are you using a JS library to do the window / modal management? I might have a look through their issues.

I have noticed issues with Wayland on Ubuntu drawing interfaces for other extensions. As a final resort, I might try researching there...

Thanks for the support!

aaroncarlucci avatar Feb 21 '24 11:02 aaroncarlucci

This is what Chrome seems to return for the lastFocusedWindow position: https://github.com/getAlby/lightning-browser-extension/blob/7928885a73ff08041f1bc6afa6b1c850af06453a/src/common/utils/window.ts#L7-L18

Here are the chrome docs for this particular function:

https://developer.chrome.com/docs/extensions/reference/api/windows

The number of pixels to position the new window from the left edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels.

Are you using a JS library to do the window / modal management? I might have a look through their issues.

No, we don't. I've linked to code used to position the window above.

reneaaron avatar Feb 22 '24 14:02 reneaaron

Thanks, I'll do a little more debugging on my side using my other machine where I have your fix/window-positioning branch checked out and installed...

aaroncarlucci avatar Feb 22 '24 14:02 aaroncarlucci

@reneaaron I've spent a few hours debugging this further. It's not completely clear yet, but here's an update with some resources I've found helpful.

  • This post seems to relate to the issue and points to the Chromium code where the error gets triggered, suggesting that in computing the bounds, availHeight and availWidth are important.
  • At one point, I managed to repeatedly get the modal to appear consistently after changing the service worker windowWidth and windowHeight to higher values, 1000x1000 I think (which seemed counter intuitivie), but I lost this test case and wasn't able to recover it.
  • After loading primal.net, I'm now running the console command window.screen to output the working dimensions. In the screenshot you'll see that availHeight is 622. The resolution for the display is 1920x1080. I haven't computed out correctly the expected position of the new window and how it overlaps with the screen properties and bounds computation, but it seems relevant.

Attached two screenshots of console logs. If you're at a point of deprioritizing this, I get it, but I'm interested in helping to continue to get to the bottom of it if you are. Hope this helps.

Screenshot from 2024-02-22 20-43-05 Screenshot from 2024-02-22 20-43-50

aaroncarlucci avatar Feb 22 '24 19:02 aaroncarlucci

Did you experience similar problems with similar extension before? I think it could be helpful to further narrow down the root cause if we'd know if that is a general problem in Chrome or specific to our code. Could you maybe give it a try in Firefox as well?

reneaaron avatar Mar 08 '24 21:03 reneaaron

As an update, Firefox works, so it must be a Chromium issue. I spent some time scouring the issue queue and found this ticket which seems most relevant:

https://issues.chromium.org/issues/41287275

Unfortunately, the issue seems a bit stale :( Hopefully something can come of it. Let me know if you have any other ideas. Thanks for the support so far!

aaroncarlucci avatar Mar 11 '24 17:03 aaroncarlucci

@reneaaron After a recent Ubuntu update to both Chrome and Brave Browser which caused both programs to crash on startup, I ended up clearing out both browser local user data directories and rebuilding my browser settings from scratch. I am happy to report that this issue appears resolved after a fresh install!

I can't tell exactly what caused it, but I was still experiencing some problematic behavior after the reset while I had the nos2x extension also enabled to handle Nostr authentication. After disabling that, Alby popups have been working well, so it might have been the nos2x extension the whole time.

From my side, this issue can be closed. Perhaps it will help someone else.

aaroncarlucci avatar Apr 24 '24 06:04 aaroncarlucci

That's a pity, glad it seems to work now. Thanks for reporting back! :raised_hands:

reneaaron avatar Apr 25 '24 20:04 reneaaron