pietervdvn / MapComplete

An easy-to-use webapp to edit OpenStreetMap
https://mapcomplete.org
227 stars 92 forks source link

Login in desktop Chromium-based browsers on macOS opens OSM in new tab and fails #1867

Closed stefanb closed 7 months ago

stefanb commented 7 months ago

Possibly related to the osm.org login / authorization page being opened in a new tab, which isn't closed and just keeps reloading authorization page when clicking the authorize button. It behaves the same in incognito mode.

In Firefox it works fine and there the osm.org login / authorize page is opened in the same browser tab.

pietervdvn commented 7 months ago

Cannot reproduce on Chromium on Ubuntu Cannot reproduce on Chrome 121.0.06167.185 and 123.0.63112.86 on Windows 10 (in a VM)

Is this still an issue for you? Do you have any output from the console?

stefanb commented 7 months ago

I noticed the problem a few weeks ago when trying the app again after a long time (a year?) and has been occurring since. Chrome on macOS.

Errors in console:

stefanb commented 7 months ago

Question: is it intended for OSM login to be opened in a new browser tab? Imo that is causing the problem closing the login tab and getting back to mapcomplete app.

pietervdvn commented 7 months ago

No, the login page is supposed to load in the same tab. Can you try hitting Ctrl+F5 before logging in to force a full reload?

stefanb commented 7 months ago

Reloaded the page without cache (shift+cmd+R on macOS) produced the same result - opening the login page in new tab.

In console i could see the "Trying to log in..." and a few requests to https://mapcomplete.org/assets/...

Even manually clearing site data in developer console made no changes - the OSM login page still opened in new tab.

Observed this on Chromes on two different Macs.

stefanb commented 7 months ago

I should also add, that I am not seeing other websites opening new tabs on a whim.

stefanb commented 7 months ago

No such problem on Windows 10 when using same account (providing same set of browser extensions to rule those out).

stefanb commented 7 months ago

Tried also with a guest profile in Chrome on macOS and experienced the same problem. No problem on mobile Chrome on Android, nor in Safari on macOS. REPRODUCED on Edge on macOS!

To summarize:

OS Browser CPUs Login note
macOS Firefox arm64/M1,M2 ✅Works 2 separate macbooks
macOS Safari arm64/M1,M2 ✅Works 2 separate macbooks
macOS Edge arm64/M2 🛑 Fails different user profile, disabled both extensions (common with chrome was ublock origin)
macOS Chrome arm64/M1,M2 🛑 Fails 2 separate macbooks, profile with extensions, incognito, guest profile with no extensions, opens new tab
Windows Chrome x86-64/Ryzen 5 ✅Works tried with same set of plugins as on macOS
Android Chrome arm64-v8a ✅Works phone
Android Opera ✅Works phone
iOS Safari ✅Works phone
iOS Edge ✅Works phone
Windows Edge ✅Works
Windows Firefox ✅Works
pietervdvn commented 7 months ago

Just tested with a virtual machine running MacOS 11.7.10 with Google Chrome 123.0.6312; where I cannot reproduce this issue.

pietervdvn commented 7 months ago

I'm gonna update the VM tonight, when I have decent internet.

stefanb commented 7 months ago

With the help of local OSM community I have added a few more tested browser / OS combinations to the matrix above, all without problems.

I suspect that it wrongly sets the singlepage parameter when setting up the authentication

https://github.com/pietervdvn/MapComplete/blob/073cd692e456ae63999bfc2770d0c204dc8a1793/src/Logic/Osm/OsmConnection.ts#L549

Spec at https://github.com/osmlab/osm-auth says:

singlepage - If true, use page redirection instead of a popup (default: false)

stefanb commented 7 months ago

Interestingly, test on https://osmlab.github.io/osm-auth/ opens new tab in my chrome and then closes it, but in Firefox it opens a popup window and then closes it. In both cases the login succeeds.

stefanb commented 7 months ago

It also works in both Firefox and Chrome on https://osmlab.github.io/osm-auth/ if i choose the "single page" checkbox, without opening any tabs or popup windows.

pietervdvn commented 7 months ago

I've enabled 'single page' mode in all cases on dev.mapcomplete.org. Would you mind testing there?

stefanb commented 7 months ago

Yay, it works in both Chrome and Edge on macOS where it previously failed 🎉 🥳 But of course other browsers should be tested too. Thanks for setting up the test!

stefanb commented 7 months ago

Works also in Firefox, but haven't tested in iframe (is this legit use case or should it escape iframes?) nor PWA.