Skip to content
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

Use CustomTabs instead of WebView for login #4973

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnvan7
Copy link

Summary

This PR implements Custom Tabs instead of WebView for login.

Using Custom Tabs instead of WebView offers several advantages:

  • Performance and Speed: Custom Tabs leverage the user's preferred browser, which is optimized for performance and speed. This results in faster loading times compared to WebView.

  • Security: Custom Tabs inherit the security features of the browser, including safe browsing, sandboxing, and other security measures. WebView, on the other hand, requires additional handling to ensure security.

  • User Experience: Custom Tabs provide a seamless user experience by allowing users to stay within the app while browsing. They support features like saved passwords, autofill, and payment methods, which are not available in WebView.

  • Maintenance: Using Custom Tabs reduces the maintenance overhead as they automatically update with the browser. WebView requires manual updates and handling of web content rendering.

By integrating Custom Tabs, we can enhance the app's performance, security, and user experience while reducing maintenance efforts.

Consider also this article

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @johnvan7

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft January 13, 2025 10:01
@johnvan7 johnvan7 marked this pull request as ready for review January 13, 2025 10:09
@jpelgrom
Copy link
Member

jpelgrom commented Jan 13, 2025

Thanks for the suggestion, but your description feels very generic and also not always correct (WebView is updated the same way as a browser).

This breaks our unofficial support for cookie/redirects during the login because it is now happening outside the WebView and not available after logging in 🤔. I wonder if that's worth the benefit - Home Assistant is not 100% like normal OAuth.

@johnvan7
Copy link
Author

Thanks for the reply.
Regarding the fact that WebView is updated in the same way as the browser, I found myself in this situation with my old tablet that I use for Home Assistant.
It has an outdated version of Android WebView that, unfortunately, cannot be updated. However, it has Google Chrome installed, which is more up-to-date. When I log in, the WebView cannot display the page correctly because it is too complex, preventing access. By using CustomTabs instead, the page opens with the Chrome engine, allowing access.
The redirect is intercepted by receiving an intent with the URL 'homeassistant://auth-callback'.

So, I understand your reasoning, and it is appropriate to proceed as you deem most appropriate.

@jpelgrom
Copy link
Member

When I log in, the WebView cannot display the page correctly because it is too complex, preventing access. By using CustomTabs instead, the page opens with the Chrome engine, allowing access.

How would switching to custom tabs for login help here, as you can now login but the main UI is still using WebView and won't be able to load? The main UI won't switch because of customizations/native integration?

@johnvan7
Copy link
Author

Main UI seems to work, I think login page is not working for background animations.
I didn't check if the whole app is using WebView, my bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants