getAlby / lightning-browser-extension

The Bitcoin Lightning Browser Extension that brings deep Lightning & Nostr integration to the web. Wallet interface to multiple lightning nodes and key signer for Nostr, Liquid and onchain use.
https://getalby.com/#extension
MIT License
539 stars 194 forks source link

Extension prompts are not being opened on multi-monitor setups #3027

Closed aaroncarlucci closed 6 months ago

aaroncarlucci commented 9 months ago

Is there an existing issue for this?

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

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

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

reneaaron commented 9 months ago

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?

aaroncarlucci commented 9 months ago

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...

reneaaron commented 9 months ago

@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 commented 9 months ago

@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!

aaroncarlucci commented 9 months ago

@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 commented 9 months ago

@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

reneaaron commented 9 months ago

@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?

aaroncarlucci commented 9 months ago

@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...

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!

reneaaron commented 9 months ago

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.

aaroncarlucci commented 9 months ago

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 commented 9 months ago

@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.

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

reneaaron commented 8 months ago

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?

aaroncarlucci commented 8 months ago

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 commented 6 months ago

@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.

reneaaron commented 6 months ago

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