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

Hitting the back button on youtube videos doesn't work correctly #29432

Closed
wknapik opened this issue Mar 30, 2023 · 54 comments
Closed

Hitting the back button on youtube videos doesn't work correctly #29432

wknapik opened this issue Mar 30, 2023 · 54 comments
Assignees

Comments

@wknapik
Copy link
Contributor

wknapik commented Mar 30, 2023

Description

Steps to Reproduce

  1. Go to youtube.com
  2. Click on any video
  3. Click the back button
  4. The url in the address bar changes, but the video page is still displayed

Actual result:

Previous page not loaded

Expected result:

Previous page loaded

Reproduces how often:

A few tries should be enough

Brave version (brave://version info)

Brave 1.49.132 Chromium: 111.0.5563.147 (Official Build) (64-bit)
Revision 029fd65a4dd711d1078468ed2206999cec86066b-refs/branch-heads/5563@{#1239}
OS Linux

Version/Channel Information:

  • Can you reproduce this issue with the current release? Yes
  • Can you reproduce this issue with the beta channel? Yes
  • Can you reproduce this issue with the nightly channel? Yes

Other Additional Information:

  • Does the issue resolve itself when disabling Brave Shields? No
  • Does the issue resolve itself when disabling Brave Rewards? n/a
  • Is the issue reproducible on the latest version of Chrome? No

Miscellaneous Information:

@srirambv
Copy link
Contributor

+1 on this. Have seen it a few times on macOS as well but not always.

@jmartinez77x
Copy link

I've experienced this as well

@Nyxet
Copy link

Nyxet commented Apr 4, 2023

Nonstop here as well.

@pilsnerbeer
Copy link

this needs to be resolved

@ArtFlag
Copy link

ArtFlag commented Apr 26, 2023

Same problem here but just to be more accurate:

This seems to mostly happen or perhaps only happen from https://www.youtube.com/feed/subscriptions, displaying a video, then going back to the subscription page.

@asheroto
Copy link

asheroto commented Apr 27, 2023

I've experienced this too, was about to create a new issue but found this one.

I'm not sure if this only happens when searching through the site, or if it's only when going directly to the search URL. I couldn't get it to happen when I went through the YouTube site to search, but if I went directly to the search URL, I had the issue. Not sure if it happens both ways or not.

How I reproduced the bug:
1.) Go to https://www.youtube.com/results?search_query=ghost
2.) Go back
3.) If it works, append a number and increment like "ghost 2", "ghost 3", etc, keep clicking on videos and going back

The weird thing is that it doesn't happen every time. It can be hard to reliably reproduce. Here's a video I recorded of my screen showing the link to search "ghost" working, the link to search "ghost 2" working, but when I search "ghost 3" and hit back, it doesn't work. Keep an eye on the URL and you'll see that the URL changes but not the webpage. I don't think the search query itself matters, this is just an example of quickly searching.

Perhaps this has something to do with the page being fully loaded or not, and perhaps it's caused by the YouTube JavaScript on their page updating the page URL, rather than the browser itself? Not sure though!

Bug is visible at 00:15.

out.mp4

I actually got this bug to happen on the Brave mobile app (Android), too. But I was only able to reproduce it when the YouTube was in "Desktop Site" mode. I wasn't able to reproduce on the mobile version. Note that the URL says "results" instead of "watch".

results = search
watch = video

Because the video is partially loaded, this makes me think it has something to do with the way the page is initialized in Brave.

Screenshot_2023-04-26-23-06-30-88_e4424258c8b8649f6e67d283a50a2cbc (Small)

@neilx11
Copy link

neilx11 commented Apr 29, 2023

I get this too: I am on Firefox Desktop browser.
It seems to happen when I leave browser untouched overnight, and try to pick up where I left off the next day; except that I can't. Previous history vanishes and current page refreshes and back button doesn't work, then back button gets greyed out and unworkable. It's like somebody doesn't want me continuing my research on something, or when I simply want to play a video from the previous days log that would be on the back button. Also, as of late. Open YouTube browser will refresh sometime after midnight, even if you're watching a video. The damn page resets, with again, history being lost on the back button, and current page reloading resulting in you having to watch or play the video from the beginning. You have No Choice!! Since when did Russia start controlling our browsers!? You get what I mean now!? I'm looking and hoping for someone to have a solution. I am not a programmer. So I do not have the means or knowledge to fix this problem. If I did, I would probably create an extension to get around this problem. Just like someone created the "Return YouTube Dislike Button", and Easy "YouTube Video Downloader". So I'm hoping some creator will make an extension that will halt these various problems with the YouTube back button. And defeat whatever YouTube (or whoever it is) is trying to do. I don't like my previous videos from the history being erased. I am a Firefox user, I did not realize I was posting on a Brave commentary board. I hope someone will create an extension that will stop this back button problem that youtube / aka Google has created!

@Rowsol
Copy link

Rowsol commented Apr 29, 2023

Very annoying but I've seen firefox users complaining about this as well. It's been happening for a year or so it seems.

@wknapik
Copy link
Contributor Author

wknapik commented May 11, 2023

cc @rebron

@rebron rebron added release-notes/include priority/P2 A bad problem. We might uplift this to the next planned release. google feature/history and removed OS/Linux OS/macOS labels May 19, 2023
@kaytwo
Copy link

kaytwo commented May 19, 2023

I'm seeing the same thing on GitHub's new code browser as well - history pops, but content does not change until refreshing the page. Can't repro on Chrome Stable.

@neilx11
Copy link

neilx11 commented May 19, 2023

I am a Firefox user and posted a previous comment in this section.
And I am having the same problem, very annoying!! My previous comment is more detail. And I make a suggestion to any maker of Extensions!! Why youtube is doing this non-sense is beyond me!! Another thing to annoy the user! First, it was "take away user's email notifications!" then it was "use hearts instead of star rating system!" And several other annoyances!
And I am Firefox Desktop browser.

@linqen
Copy link

linqen commented Jun 28, 2023

Same to me (using brave).
So relief that I found this report on Brave Browser repo.

@asheroto
Copy link

@neilx11 are you having an issue in Brave?

@ryanbr
Copy link

ryanbr commented Jun 28, 2023

I made a change recently try Updating Brave Ad Block Updater - Version: 1.0.348 in brave://components. Then refreshing Youtube webpage.

@asheroto
Copy link

asheroto commented Jun 28, 2023

Thanks @ryanbr.

I am using 1.0.348 and unfortunately still have the same bug. Looks like it happens in Private windows too.

The way I test it is to go to
https://www.youtube.com/results?search_query=asdf
then
https://www.youtube.com/results?search_query=asdf2
then
https://www.youtube.com/results?search_query=asdf3
and continue on until the bug is reproduced

Interestingly enough I can't get it to happen when you are already on the page and then search for "asdf" etc. It seems to happen when you go to the page directly. Although the bug may exist when the page is already loaded, I'm not sure, but I've had the most luck reproducing the bug by going to the page directly.

Here's another demo...

brave_CiFEd7O7Sh.mp4

I'm using the back button on my mouse. It seems to work fine when using the search box inside the YouTube page, but when going to the URL directly, whether typing it in, using it as a search engine in Brave (typing "youtube asdf6"), or even clicking on a link from a search engine like Google/Brave/etc the bug will present itself. In the demo above, notice how around second 23 (changing the URL to asdf6) the screen flashes. That's when I press the back button.

@wknapik
Copy link
Contributor Author

wknapik commented Jun 28, 2023

@ryanbr after updating to 1.0.348, I tried on each channel in a fresh profile and hit the issue exactly once per channel, on the first try, and then it never reproduced again. In my main profile, on the release channel, where I haven't restarted the browser, the update didn't seem to have an effect and the issue is still fully there.

@ryanbr
Copy link

ryanbr commented Jun 28, 2023

With shields up, no extensions. When hitting the back button what does it show in the console?

@asheroto
Copy link

With shields up, no extensions. When hitting the back button what does it show in the console?

Shields are up...
image

All debugging levels turned on in console.


When searching https://www.youtube.com/results?search_query=asdf20a on a new profile

Details

Shields up...

image

Shields down...

image

When searching https://www.youtube.com/results?search_query=asdf20b on a new profile...

Details

Shields up...

image

Shields down...

image

brave://components...
image

In my tests, I had the issue happen whether shields were up or not, on any profile, and have used brave://restart.

Version...
image

@ryanbr
Copy link

ryanbr commented Jun 28, 2023

Try adding @@/generate_204 into brave://adblock custom rules, save and reload YT.

@asheroto
Copy link

Same problem, but keep in mind even with shields down it does the same thing.

@szilardszaloki
Copy link
Contributor

Closed via brave/adblock-resources#131.

@GitAcc53
Copy link

"[closed/fixed-by-component-update]"

It's not fixed at all. I still have the same problem.

@linqen
Copy link

linqen commented Oct 17, 2023

I guess this didn't hit production yet

@StrangePeanut
Copy link

I personally haven't experienced the issue in a while.

@szilardszaloki
Copy link
Contributor

The changes were shipped via the component updater around September 13.
@GitAcc53 Would you mind letting me know the versions you see in brave://components next to Brave Ad Block Resources Library, and Brave Ad Block Updater?
Thanks!

@linqen
Copy link

linqen commented Oct 17, 2023

For me is still happening as well, versions:

Ad Block Resources Library - Version: 1.0.71
Brave Ad Block Updater - Version: 1.0.1714

@szilardszaloki
Copy link
Contributor

@linqen Would you mind checking what history.state.entryTime values you get for the affected sites in Developer Console (like I did here)?

@GitAcc53
Copy link

1.0.72, 1.0.1740
still happening

@szilardszaloki
Copy link
Contributor

@GitAcc53 @linqen What you're experiencing has the same symptoms with a different underlying cause, unfortunately. It's most probably due to some of YouTube's recent changes to their site that are being released via staged roll-outs (which affect only a certain percentage of users). Will keep an eye on that, and also would appreciate any additional info you might have — including the history.state.entryTime values you're getting for the affected sites.

@GitAcc53
Copy link

I couldn't figure out how to get the info from history.state.entryTime values, problem is still happening

@Kolgann
Copy link

Kolgann commented Dec 4, 2023

I've been encountering this issue for about a year now and can confirm it still happens fairly often for me. Strangely, it's not very consistent; I can go a day or two without seeing it once, and then another day it'll happen pretty much every single time I hit the back button in Youtube.

Brave Browser - v1.60.125
Brave Ad Block Resources - v1.0.81
Brave Ad Block Updater - v1.0.2644
Windows 11 - 10.0.22621

I was able to get the history.state.entryTime values when the issue is happening vs when it not happening, and I verified that when the issue is happening, the entryTime value does not change when pressing the back button. When the issue is not happening, the entryTime value should be smaller after pressing the back button. There were several times when I observed that this would be by an incredibly small amount (e.g. 5093.000000000022 vs 5093, or 9647.000000000022 vs 9647).

I hope this helps, let me know if I can provide any extra info. Thanks!

Btw @GitAcc53 and anyone else who has the issue and feels motivated to double-check, you can easily get these values by opening the dev console and typing 'console.log(history.state.entryTime);'.

@cyfung1031
Copy link

cyfung1031 commented Dec 28, 2023

The issue is due to the incorrectness of history state. (no entry point is stored in window.history.state)
This is a very old bug and the new YouTube engineers could not solve it.
This is not because of the JS engine used in Brave. It happens for all browsers.

That's why now the engineers trying to put ?si= ?pp= in the url.

The issue should be gone if you use Tabview Youtube.

The related code inside Tabview Youtube:
(it check and fix in every yt-navigate-start(user navigation) and yt-navigate-finish(every change of page))

  let fixHistoryStatePN = null;

  if (FIX_UNCERTAIN_HISTORY_STATE) {
    // history.state cannot be amended by the replaceState.
    // require ytd-app.replaceState
    // reason: unknown
    // the history.state is also different from the isolated script's history.state

    document.addEventListener("yt-navigate-start", (evt) => { // primary

      const data = evt.detail;
      // const entryTime = evt.timeStamp;
      const entryTime = window.performance.now(); // should be mono increasing

      Promise.resolve().then(() => {

        if (data.pageType === 'watch' && data.reload === false && typeof data.url === 'string' && data.endpoint) {

          const s = {
            "endpoint": deepClone(data.endpoint),
            "savedComponentState": {},
            "entryTime": entryTime
          }
          xReplaceState(s, data.url);

          console.debug('[tyt] FIX_UNCERTAIN_HISTORY_STATE for yt-navigate-start')
        }

      });


    }, true);


    fixHistoryStatePN = () => { // fallback

      Promise.resolve().then(() => {

        const u = `${location.pathname}${location.search}`;
        let q = /^\/watch\?v=([^=?&]+)/.exec(u);
        let vid = q ? q[1] : '';

        if (vid && (history.state === null || ((((history || 0).state || 0).endpoint || 0).watchEndpoint || 0).videoId !== vid)) {

          const s = {
            "endpoint": {
              "watchEndpoint": {
                "videoId": vid,
                "watchEndpointSupportedOnesieConfig": { // optional; object
                  "html5PlaybackOnesieConfig": {
                  }
                },
                "watchEndpointSupportedPrefetchConfig": {
                  "prefetchHintConfig": {
                    "prefetchPriority": 0,
                    "countdownUiRelativeSecondsPrefetchCondition": -3
                  }
                }
              },
              "commandMetadata": {
                "webCommandMetadata": {
                  "url": u,
                  "webPageType": "WEB_PAGE_TYPE_WATCH",
                  "rootVe": 3832
                }
              }
            },
            "savedComponentState": {},
            "entryTime": window.performance.now()
          };
          xReplaceState(s, u);
          console.debug('[tyt] FIX_UNCERTAIN_HISTORY_STATE for NULL or VideoChanged state')

        }
      });



    };


  }

@asheroto
Copy link

Good info! Thanks for that!

@Kolgann
Copy link

Kolgann commented Dec 28, 2023

Yes that's very helpful, thank you! I anecdotally hadn't noticed it in other browsers, but it is an intermittent issue and I use Brave far more than any other browser, so it seems reasonable that I just happened to not have encountered it on other browsers yet. Good to know it's not a Brave issue, and just a YouTube bug.

@Mettwasser
Copy link

Still not resolved.
I was using Opera GX for roughly 2 years and recently made the jump to brave.
I have this issue literally the entire time, and it's nerve-wrecking. I haven't had this issue on Opera GX, the solution with "TabView" didn't work for me either. I am seriously considering another browser, because this is a huge dealbreaker for me.

@bsclifton
Copy link
Member

bsclifton commented Oct 15, 2024

Hi folks - we recently made a change to our variations server which disabled the feature causing this problem (see brave/brave-variations#1224 for more info). This should be working great now. If anyone is experiencing any issues please reply back here!

@Mettwasser can you please retest? (if you're still using Brave)

@asheroto
Copy link

I tested this out using the latest version on two different computers and could not replicate the original issue. I'm think this might be fixed! Thanks for our work! Hopefully others experience the same result.

@Mettwasser
Copy link

I was staying with brave. Can't currently test it on my main PC, but it for sure works on my laptop. So I am confident it's fixed. Thank you so, so much!

@linqen
Copy link

linqen commented Oct 16, 2024

Hi folks - we recently made a change to our variations server which disabled the feature causing this problem (see brave/brave-variations#1224 for more info). This should be working great now. If anyone is experiencing any issues please reply back here!

I tested and looks like it's working! I hope so, because this issue has been around for AGES. Thank you!

@Mettwasser
Copy link

Hi folks - we recently made a change to our variations server which disabled the feature causing this problem (see brave/brave-variations#1224 for more info). This should be working great now. If anyone is experiencing any issues please reply back here!

@Mettwasser can you please retest? (if you're still using Brave)

So yes, I got to test it on my main PC, and I can confirm this is resolved. Thank you for the hard work!

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

No branches or pull requests