telegramdesktop / tdesktop

Telegram Desktop messaging app
https://desktop.telegram.org/
Other
26.23k stars 5.21k forks source link

desktop telegram (windows) not opening web-app #27886

Closed killershotpy closed 4 months ago

killershotpy commented 5 months ago

Steps to reproduce

~~1. update telegram to 5.0.1 version

  1. open any bot where opening by button web-app window
  2. window IE not load web-app content~~

upd.

  1. Set the usage rights for the "C:\Program Files (x86)\Microsoft\EdgeWebView\Application\ххх.х.хххх.хх\msedgewebview2.exe" file to the name of any user who is not an administrator or the current user.
  2. try to open any web-app via telegram
  3. you will see or not see the error from windows 10 system: "Cannot find ...\msedgewebview2.exe"

Expected behaviour

content is loaded in an IE window

Actual behaviour

image

The application hangs without loading the frontend. At the same time any application opened with any bot does not work at all.

in log file, i have this: ... [2024.05.07 02:25:13] Skipping message, because it is already in blocks! ...

with that option enabled:

{
    "view-profile-in-chats-list-context-menu": true,
    "webview-debug-enabled": true
}

I can't even open devtools to debug the problem.

Operating system

windows 10 home edition (desktop)

Version of Telegram Desktop

5.0.1 (latest)

image

Installation source

Static binary from official website

Crash ID

No response

Logs

[2024.05.07 02:23:01] Launched version: 5000001, install beta: [FALSE], alpha: 0, debug mode: [FALSE]
...
...
[2024.05.07 02:23:01] Global devicePixelRatio: 1
[2024.05.07 02:23:01] QT_DPI_ADJUSTMENT_POLICY: AdjustDpi
[2024.05.07 02:23:01] Primary screen DPI: 144, Base: 96.
[2024.05.07 02:23:01] Computed screen scale: 150
[2024.05.07 02:23:01] DevicePixelRatio: 1
[2024.05.07 02:23:01] ScreenScale: 150
...
...
[2024.05.07 02:23:02] OpenGL: QOpenGLContext created, version: 3.3.
[2024.05.07 02:23:02] OpenGL: [TRUE] (Window)
[2024.05.07 02:23:03] API Warning: not loaded minimal channel applied.
[2024.05.07 02:23:16] Skipping message, because it is already in blocks!
[2024.05.07 02:23:18] Skipping message, because it is already in blocks!
[2024.05.07 02:24:51] Skipping message, because it is already in blocks!
[2024.05.07 02:24:52] Skipping message, because it is already in blocks!
[2024.05.07 02:24:53] Skipping message, because it is already in blocks!
[2024.05.07 02:25:11] Skipping message, because it is already in blocks!
[2024.05.07 02:25:13] Skipping message, because it is already in blocks!
aivanouski commented 5 months ago

+1 windows 10 pc, @wallet not loaded and any TMA

killershotpy commented 5 months ago

related issues: https://github.com/telegramdesktop/tdesktop/issues/26978 https://github.com/telegramdesktop/tdesktop/issues/27133 https://github.com/telegramdesktop/tdesktop/issues/27251

killershotpy commented 5 months ago

+1 windows 10 pc, @wallet not loaded and any TMA

I found a solution purely by accident. When you install tdesktop, it searches by default for: C:\Program Files (x86)\Microsoft\EdgeWebView\Application\113.0.1774.57\msedgewebview2.exe

To display the contents of the web-app. When I explicitly set the telegram.exe executable to "open as Administrator", windows gave me the error "Cannot find ... C:\Program Files (x86)\Microsoft\EdgeWebView\Application\113.0.1774.57\msedgewebview2.exe".

It doesn't matter if you have it enabled in the experimental settings: "webview-debug-enabled": true

or not, it doesn't matter. Telegram tries to use \msedgewebview2.exe to display web-app content.

It also looks like telegram desktop is passing data to Edge, I wonder what their user agreement says about this? @john-preston

aivanouski commented 5 months ago

@killershotpy thx, you are right! Problem was with EdgeWebView

john-preston commented 5 months ago

@killershotpy TDesktop tries to use WebView2 component to show the web-apps. "webview-debug-enabled" enables the Inspector working in the webview when it runs, but in your case the webview simply can't load for some reason.

I don't use any hardcoded paths to search for the webview, I use WebView2 SDK through the Microsoft.Web.WebView2 NuGet package.

killershotpy commented 5 months ago

@killershotpy TDesktop tries to use WebView2 component to show the web-apps. "webview-debug-enabled" enables the Inspector working in the webview when it runs, but in your case the webview simply can't load for some reason.

I don't use any hardcoded paths to search for the webview, I use WebView2 SDK through the Microsoft.Web.WebView2 NuGet package.

As I wrote earlier, telegram desktop uses the default WebView from microsoft edge for some reason, this was diagnosed after explicitly disabling access to the microsoft edge folder. This explicitly means that data is transmitted to third parties without the user's consent.

john-preston commented 5 months ago

Well, if the WebView2 could not be initialized, fallback to WebView Legacy is made.

Telegram bot web apps on all platforms work in system webview components, I see no difference in TDesktop case here.

killershotpy commented 5 months ago

Что ж, если WebView2 не удалось инициализировать, выполняется возврат к WebView Legacy.

Веб-приложения Telegram-ботов на всех платформах работают в компонентах системного веб-просмотра, в случае с TDesktop я не вижу здесь никакой разницы.

Maybe you should specify somewhere to users that if their default webview is not available, then you will not have web applications opening which are initialized through telegram?

john-preston commented 5 months ago

Well, there are some checks in code about the availability of WebView, two backends are checked on Windows. Maybe the checks aren't enough, then I'm all ears how to make them better.

WebView2 checks the version of the browser used for the webview:

https://github.com/desktop-app/lib_webview/blob/master/webview/platform/win/webview_windows_edge_chromium.cpp#L761

Legacy WebView tries to create a control process:

https://github.com/desktop-app/lib_webview/blob/master/webview/platform/win/webview_windows_edge_html.cpp#L171

If none of those worked you should see a message like that one:

image

aivanouski commented 5 months ago

@john-preston Is it possible to integrate webview to package instead of referrence? In my case I had corrupted folder on windows C:\Program Files (x86)\Microsoft\EdgeWebView\ It was moved to Z: disk space. And portable and standalone version both was in infinite loop to trying to load TMA. I guess portable version should incapsulate webview reference inside her bundle.

ilya-fedin commented 5 months ago

Is it possible to integrate webview to package instead of referrence?

tdesktop uses Webview2 exactly because the intention is to not to provide a huge web browser bundle. Otherwise tdesktop would just use Qt WebEngine (which is much simpler to integrate).

killershotpy commented 5 months ago

Is it possible to integrate webview to package instead of referrence?

tdesktop uses Webview2 exactly because the intention is to not to provide a huge web browser bundle. Otherwise tdesktop would just use Qt WebEngine (which is much simpler to integrate).

as I suggested above - the user should definitely be able to see the explicit behavior of their application.

thus it is necessary to add a system or (and) client alert that will show the absence of default webview.

as well as a link to the documentation or at least this (or/and) ishy, so that you can immediately understand what the reason is.

By default, the application is not run as administrator, and for this reason, system alerts (alerts) are not shown.

Again, I discovered the problem purely by accident, because I was running the application "as administrator".

Also, there are some related ish I have listed above, which most likely also depend on the system pre-installed webview.

and also there is another solution that I would suggest: show a system dialog box with a choice of browser to open the target resource, in cases where the default system webview is not found.

This would solve several problems at once:

  1. lack of system webview, which may not be pre-installed in the system
  2. no notifications (system or from the Telegram client) about the error of searching for this webview.
  3. selecting an already installed browser to open it

Unfortunately, I realize that this will introduce a number of inconveniences and reduced functionality, such as:

  1. opening the telegram dialog box by clicking on 3 dots (vertical ...)
  2. native passing of arguments for the same authorization via telegram account in the web application

However, the same web.telegram, explicitly passes the URL address with arguments and authorization or other actions embedded in this or that web application.

I've been working with web apps and mobile apps for a long time, but I have no idea how arguments are passed in desktop apps.

killershotpy commented 5 months ago

Well, there are some checks in code about the availability of WebView, two backends are checked on Windows. Maybe the checks aren't enough, then I'm all ears how to make them better.

WebView2 checks the version of the browser used for the webview:

https://github.com/desktop-app/lib_webview/blob/master/webview/platform/win/webview_windows_edge_chromium.cpp#L761

Legacy WebView tries to create a control process:

https://github.com/desktop-app/lib_webview/blob/master/webview/platform/win/webview_windows_edge_html.cpp#L171

If none of those worked you should see a message like that one:

I apologize for the long time reply, above see my comment about the proposed solution.

about your screenshot, I'm not quite sure if I "should have seen it by now" or if you will update the release and users will "further see" the lack of webviews?

ilya-fedin commented 5 months ago

show a system dialog box with a choice of browser to open the target resource, in cases where the default system webview is not found.

I'm not sure what would that give. As you can see, there's already a text for such situation, the problem is system APIs are misbehaving and saying the webview is successfully initialized despite it's not. Whatever you would like to show, you just can't detect whether it's found or not in first place with this exact breakage of system files.

john-preston commented 5 months ago

@killershotpy The problem is that in case of some system configuration the code that I use to detect if the webview is available isn't working correctly -- it should show the "install webview2 runtime" with a link, but it doesn't show anything, as if webview was successfully initialized.

If you can provide a step-by-step way to bringing the system to the state where this happens I can try to make it myself and try to fix the detection.

killershotpy commented 5 months ago

@killershotpy The problem is that in case of some system configuration the code that I use to detect if the webview is available isn't working correctly -- it should show the "install webview2 runtime" with a link, but it doesn't show anything, as if webview was successfully initialized.

If you can provide a step-by-step way to bringing the system to the state where this happens I can try to make it myself and try to fix the detection.

of course, here's the step-by-step detailed instructions:

  1. install window 10
  2. go to the folder "C:\Program Files (x86)\Microsoft\".
  3. set permissions and owner of the "EdgeWebView" folder to any non-administrator group, e.g. "local_services".
  4. apply the changes to the folder and all files inside it.
  5. run telegram as a normal user (not administrator).
  6. try to open any web application. in this scenario, you will NOT get a system notification

AND

  1. install windows 10
  2. navigate to "C:\Program Files (x86)\Microsoft\" folder.
  3. set the permissions and owner of the "EdgeWebView" folder to any non-admin group, such as "local_services".
  4. apply the changes to the folder and all files in it.
  5. run telegram as administrator.
  6. try to open any web application. In this scenario, you will get a notification from the system that the file "msedgewebview2" is not found.
Aokromes commented 5 months ago

@killershotpy The problem is that in case of some system configuration the code that I use to detect if the webview is available isn't working correctly -- it should show the "install webview2 runtime" with a link, but it doesn't show anything, as if webview was successfully initialized. If you can provide a step-by-step way to bringing the system to the state where this happens I can try to make it myself and try to fix the detection.

of course, here's the step-by-step detailed instructions:

  1. install window 10
  2. go to the folder "C:\Program Files (x86)\Microsoft".
  3. set permissions and owner of the "EdgeWebView" folder to any non-administrator group, e.g. "local_services".
  4. apply the changes to the folder and all files inside it.
  5. run telegram as a normal user (not administrator).
  6. try to open any web application. in this scenario, you will NOT get a system notification

AND

  1. install windows 10
  2. navigate to "C:\Program Files (x86)\Microsoft" folder.
  3. set the permissions and owner of the "EdgeWebView" folder to any non-admin group, such as "local_services".
  4. apply the changes to the folder and all files in it.
  5. run telegram as administrator.
  6. try to open any web application. In this scenario, you will get a notification from the system that the file "msedgewebview2" is not found.

so, you basicaly say to reproduce this bug you must break windows.

killershotpy commented 5 months ago

@killershotpy The problem is that in case of some system configuration the code that I use to detect if the webview is available isn't working correctly -- it should show the "install webview2 runtime" with a link, but it doesn't show anything, as if webview was successfully initialized. If you can provide a step-by-step way to bringing the system to the state where this happens I can try to make it myself and try to fix the detection.

of course, here's the step-by-step detailed instructions:

  1. install window 10
  2. go to the folder "C:\Program Files (x86)\Microsoft".
  3. set permissions and owner of the "EdgeWebView" folder to any non-administrator group, e.g. "local_services".
  4. apply the changes to the folder and all files inside it.
  5. run telegram as a normal user (not administrator).
  6. try to open any web application. in this scenario, you will NOT get a system notification

AND

  1. install windows 10
  2. navigate to "C:\Program Files (x86)\Microsoft" folder.
  3. set the permissions and owner of the "EdgeWebView" folder to any non-admin group, such as "local_services".
  4. apply the changes to the folder and all files in it.
  5. run telegram as administrator.
  6. try to open any web application. In this scenario, you will get a notification from the system that the file "msedgewebview2" is not found.

so, you basicaly say to reproduce this bug you must break windows.

I haven't tested the behavior on other systems, but I've attached similar problems above in the comments, I assume they occur for the same reason - lack of a basic webview

ilya-fedin commented 5 months ago

but I've attached similar problems above in the comments

they all are closed as solved

john-preston commented 5 months ago

@killershotpy Your instructions apparently break the new one, WebView2 runtime. Because I've broken it that way (I can't even open that folder from my or administrative account) and now the modern WebView2 runtime can't initialize, but the fallback to the legacy WebView based on the legacy Edge browser still works fine. In your case it looks like you had broken by permissions issue the new WebView2 runtime + somehow broken the legacy Edge as well. Idk 🤷

killershotpy commented 5 months ago

@killershotpy Your instructions apparently break the new one, WebView2 runtime. Because I've broken it that way (I can't even open that folder from my or administrative account) and now the modern WebView2 runtime can't initialize, but the fallback to the legacy WebView based on the legacy Edge browser still works fine. In your case it looks like you had broken by permissions issue the new WebView2 runtime + somehow broken the legacy Edge as well. Idk 🤷

Logically, I've banned webviewer access.

Another person above said the same thing - he had a non-standard path to the webviewer.

There is no return to the outdated version, because access is denied at the level of the webwiev folder itself, and outdated versions lie deeper:

image
ilya-fedin commented 5 months ago

@killershotpy what @john-preston points out is your steps wasn't enough for him to reproduce the issue, web bots still work but with older system API. You're missing something in those steps.

killershotpy commented 5 months ago

@killershotpy what @john-preston points out is your steps wasn't enough for him to reproduce the issue, web bots still work but with older system API. You're missing something in those steps.

but the fallback to the legacy WebView based on the legacy Edge browser still works fine

John writes that "but the fallback to the legacy WebView based on the legacy Edge browser still works fine".

but doesn't say where it is? Point me in the right direction and I'll look it up.

ilya-fedin commented 5 months ago

but doesn't say where it is?

Personally I don't know. Not sure @john-preston knows. That might be something you have to find and tell us.

killershotpy commented 5 months ago

but doesn't say where it is?

Personally I don't know. Not sure @john-preston knows. That might be something you have to find and tell us.

How can I find a default webview with an older API? If I don't have it, in my case it won't revert to an older version and start the webview.

If you could point out the path where it should be I could take a look, as I don't know what paths or path variables in tdesktop you are using.

Also, you might be trying to pull variables from env system, which could also be where the error lies

The error could also be in the registry, which I also modified by removing all the microsoft edge junk. Maybe you are relying on the registry to find an older webview API?

ilya-fedin commented 5 months ago

If I don't have it, in my case it won't revert to an older version and start the webview.

It should then show the text as @john-preston shown earlier. But I don't think that's possible as it should be integrated in Windows 11. The only supported system not having it out of the box is Windows 7. And, well, it's explicitly blacklisted as tdesktop fails to initialize webview on it even after manual installation of the component.

If you could point out the path where it should be I could take a look, as I don't know what paths or path variables in tdesktop you are using.

Well, tdesktop doesn't use paths, it uses system APIs, you can see how the code looks like: https://github.com/desktop-app/lib_webview/blob/master/webview/platform/win/webview_windows_edge_html.cpp#L171-L205 (this is the legacy API while the edge_chromium file implements webview2)

That's why no one knows the paths. Unless you can remember what you have broken in the system, it might be impossible to repair it. In which case it might be better to re-install your system and close the issue.

github-actions[bot] commented 4 months ago

This issue has been automatically closed because no developer succeeded to reproduce the issue with the given reproduction steps. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you find what's missing to reproduce the issue so that we can investigate further.

Note that GitHub is a developer communication platform. If you're an ordinary user seeking for help, get to support crew via Settings -> Ask question in the application.