OtterBrowser / otter-browser

Otter Browser aims to recreate the best aspects of the classic Opera (12.x) UI using Qt5
https://otter-browser.org
GNU General Public License v3.0
1.8k stars 277 forks source link

Page title not always saved when session is closed #217

Closed Katarn closed 9 years ago

Katarn commented 10 years ago

On this page, when I launch the browser and this tab is not active, the title of the tab is loaded with the value of "(Untitled)", perhaps because the title is sets dynamically through JavaScript.

http://www.timeout.ru/msk/feature/35923/pic-423730

Decme commented 10 years ago

Your imagehost is broken. I recommend hosting your screenshots on http://pomf.se/

Katarn commented 10 years ago

@Decme, this is not screenshot, it example link when bug is reproduced. @Emdek, thank you! I'm testing it on this weekend.

Katarn commented 10 years ago

@Emdek, this patch does not works, please test it with url from the first post.

  1. Open url in new tab
  2. Set active any other tab
  3. Restart the browser -- tab from step 1 have "(Untitled)" title
Emdek commented 10 years ago

@Katarn, it's not saved or not restored? Works for me.

Katarn commented 10 years ago

@Emdek, not saved. In default.ini file param title have "" value:

[1/11/History/1]
url="http://www.timeout.ru/msk/feature/35923/pic-423730"
title=""
position=0,0
zoom=100
Emdek commented 10 years ago

@Katarn, is it saved if another tab was opened before closing window?

Katarn commented 10 years ago

@Emdek, this record appearance in session file immediately after I click middle button on link in the first post. After that, it does not change. Not in the case of activation of the tab and not in the case if I close browser.

Emdek commented 10 years ago

@Katarn, text in the tab bar is correct? Both tab bar and session get it from the same source.

Katarn commented 10 years ago

@Emdek, no, after browser start title in tab bar is "(Untitled)". I remind you that only in the case if you start browser with active another tab.

Emdek commented 10 years ago

@Katarn, but I'm asking if it is correct before closing. ;-)

Katarn commented 10 years ago

@Emdek, yes, before browser closing title in tab bar is correct.

Emdek commented 10 years ago

@Katarn, is it still present with current master?

Katarn commented 10 years ago

@Emdek, yes, the problem is still reproduced.

Katarn commented 9 years ago

I debug this problem some time ago. It is very likely that this is a upstream issue.

Emdek commented 9 years ago

@Katarn, upstream in QtWebKit or elsewhere?

Katarn commented 9 years ago

@Emdek, now I do not remember, I will look later. :)

Katarn commented 9 years ago

@Katarn, upstream in QtWebKit or elsewhere?

In QtWebKitWebWidget::getHistory() method line entry.title = item.title(); returns "" value when the page opens. Do I understand correctly place in the code where occurs the error?

https://github.com/Emdek/otter/blob/master/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp#L1832

Emdek commented 9 years ago

@Katarn, it could be that one, if it insists that title is empty even if it is not. It could be also saved incorrectly, read back incorrectly or incorrectly restored in QtWebKitWebWidget::setHistory(). You could try to print it with qDebug() << item.title(); and add similar output in other places to track current values when storing and restoring.

Katarn commented 9 years ago

I now have little time to research this bug, but I can say that QtWebEngine not have this issue. When I have more time, I'll see where the error lies in QtWebKit.

615

Emdek commented 9 years ago

@Katarn, any progress on this issue?

Katarn commented 9 years ago

@Emdek,

I append next qDebug() lines to setHistory() method (lines 1830, 1831):

for (int i = 0; i < history.entries.count(); ++i)
{
    QVariantList data;
    data.append(-1);
    data.append(history.entries.at(i).zoom);
    data.append(history.entries.at(i).position);

    qDebug() << "Title: ";
    qDebug() << history.entries.at(i).title;

    m_webView->page()->history()->itemAt(i).setUserData(data);
}

and in console I see next output when I first load of tab with problem page:

Debug: Title:  (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:1830, virtual void Otter::QtWebKitWebWidget::setHistory(const Otter::WindowHistoryInformation&))
Debug: "" (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:1831, virtual void Otter::QtWebKitWebWidget::setHistory(const Otter::WindowHistoryInformation&))
Emdek commented 9 years ago

@Katarn, so it reads it back as an empty string. Try to catch item.title() in QtWebKitWebWidget::getHistory(), in loop.

Katarn commented 9 years ago
for (int i = 0; i < historyCount; ++i)
{
    const QWebHistoryItem item = history->itemAt(i);
    WindowHistoryEntry entry;
    entry.url = item.url().toString();
    entry.title = item.title();
    entry.position = item.userData().toList().value(PositionEntryData, QPoint(0, 0)).toPoint();
    entry.zoom = item.userData().toList().value(ZoomEntryData).toInt();

    qDebug() << "getHistoryTitle";
    qDebug() << item.title();

    information.entries.append(entry);
}
Debug: setHistoryTitle:  (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:1830, virtual void Otter::QtWebKitWebWidget::setHistory(const Otter::WindowHistoryInformation&))
Debug: "" (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:1831, virtual void Otter::QtWebKitWebWidget::setHistory(const Otter::WindowHistoryInformation&))
Debug: getHistoryTitle (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:2335, virtual Otter::WindowHistoryInformation Otter::QtWebKitWebWidget::getHistory() const)
Debug: "GitHub" (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:2336, virtual Otter::WindowHistoryInformation Otter::QtWebKitWebWidget::getHistory() const)
Debug: getHistoryTitle (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:2335, virtual Otter::WindowHistoryInformation Otter::QtWebKitWebWidget::getHistory() const)
Debug: "" (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:2336, virtual Otter::WindowHistoryInformation Otter::QtWebKitWebWidget::getHistory() const)
Debug: getHistoryTitle (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:2335, virtual Otter::WindowHistoryInformation Otter::QtWebKitWebWidget::getHistory() const)
Debug: "GitHub" (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:2336, virtual Otter::WindowHistoryInformation Otter::QtWebKitWebWidget::getHistory() const)
Debug: getHistoryTitle (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:2335, virtual Otter::WindowHistoryInformation Otter::QtWebKitWebWidget::getHistory() const)
Debug: "" (../otter-debug/src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp:2336, virtual Otter::WindowHistoryInformation Otter::QtWebKitWebWidget::getHistory() const)

By the way, I use lazy loading tabs. When starting the browser was open tab with Github, then I switched to the problematic tab.

Emdek commented 9 years ago

@Katarn, if item.title() is empty then it's something wrong with QtWebKit.