The program on PyQt5 + QWebEngineView closes when loading youtube.music site after about 3-4 seconds after opening, without any error, while any other site loads without any problems and the program does not close itself. This problem started today, yesterday youtube.music was opening successfully in QWebEngineView. I'm using windows 10 21h1.
After I realized that the problem is not in my code I tried to write a completely clean code with PyQt5 + QWebEngineView and opening music.youtube.com, but without success.
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
app = QApplication([])
window = QMainWindow()
central_widget = QWidget()
layout = QVBoxLayout(central_widget)
webview = QWebEngineView()
page = QWebEnginePage()
webview.setPage(page)
page.load(QUrl("https://music.youtube.com"))
layout.addWidget(webview)
window.setCentralWidget(central_widget)
window.show()
app.exec()
I also tried clearing chrome browser cookies, but still no luck. I don't know what to do. The site itself opens successfully in both Firefox and Chrome. I also tried to go to music.youtube.com through google search engine, but still the same when opening the program closes without error:( What to do? How to fix it? P.S: If you compile this code into an .exe, everything will work properly.
The whole problem was a QWebEngine cookie. If you find the folder with your QWebEngine cookies in the directory C:\Users\USERNAME\AppData\Local and delete the folder Service Worker in the directory YourAppName\QtWebEngine\Default, everything will work and the sites' data will not be lost.