YouTube-Music icon indicating copy to clipboard operation
YouTube-Music copied to clipboard

App fails to load https://music.youtube.com with error

Open jscheel opened this issue 2 years ago • 20 comments

I've started getting a blank screen when opening the app. I built from source, enabled the inspector, and I'm seeing this error:

[Error] FetchEvent.respondWith received an error: TypeError: undefined is not an object (evaluating 'a.preloadResponse.then')
[Error] Cannot load https://music.youtube.com/.
[Error] Failed to load resource: FetchEvent.respondWith received an error: TypeError: undefined is not an object (evaluating 'a.preloadResponse.then') (music.youtube.com, line 0)

I can get it to go to any other page, including Youtube itself. But Youtube Music fails every time now.

jscheel avatar Apr 29 '22 15:04 jscheel

Also getting this from the app's debugging:

[Process] 0x7fc67680b220 - [pageProxyID=5, webPageID=6, PID=7102] WebPageProxy::didFailProvisionalLoadForFrame: frameID=4, domain=WebKitServiceWorker, code=0

jscheel avatar Apr 29 '22 15:04 jscheel

So, super weird, but I cleared all the data out before loading the web view via:

WKWebsiteDataStore.default().removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), modifiedSince: Date(timeIntervalSince1970: 0), completionHandler: {})

and it loaded. However, nothing is playing.

jscheel avatar Apr 29 '22 16:04 jscheel

It appears to be failing to load the player code:

Cannot load https://music.youtube.com/s/player/9cdfefcf/player_ias.vflset/en_US/base.js.

jscheel avatar Apr 29 '22 16:04 jscheel

and it loaded. However, nothing is playing.

Similar stuff happening to me. It was working fine until yesterday. But since this morning nothing is playing; while navigation/search/etc works fine.

evsasse avatar Apr 29 '22 21:04 evsasse

I'm having a similar issue, just downloaded from release tags and nothing is playing. I'm running big sur

JuampiCarosi avatar May 01 '22 20:05 JuampiCarosi

Hrmmm. I also periodically open the app to a blank screen. Usually if I quit and re-open the app, it'll eventually start working again.

Thanks for the debug messages! I hadn't managed to capture any on my end. From those messages, do you think it's something on our end due to the custom JS we inject?

TimOliver avatar May 02 '22 02:05 TimOliver

@TimOliver no, unfortunately it's not. This is caused by a bad service worker registration. The error that is throw is coming from the service worker trying to handle a prefetch of the file, and crashing because the fetch event doesn't support preloadResponse. Makes me think there's something wrong with the cache maybe. No clue how it could have possibly gotten into that state. However, I ended up unregistering the service worker and got it working again. Unfortunately, on the next load, it's broken again.

I found a bug report that looks like the issue here: https://developer.apple.com/forums/thread/702755. I tried the suggested solution (loading a different page first), but it seems to only work intermittently.

jscheel avatar May 02 '22 16:05 jscheel

Ok, I have a possible solution. It's a hammer, but it seems to be working: I've set up a ContentRuleList in the WkWebView to prevent sw.js from loading. This prevents the service worker from registering, which in turn prevents the prefetching/caching of the code that seems to be broken for some reason. I need to clean up all my other test code to make sure this works consistently.

jscheel avatar May 02 '22 16:05 jscheel

Added a PR for this

jscheel avatar May 02 '22 16:05 jscheel

Not sure if it's related, but I just allowed an update to the latest version and now it won't play. Could be it's unrelated and it was already broken for me - this is the first time today I've tried it.

mark-pictor-csec avatar May 02 '22 17:05 mark-pictor-csec

Thanks @jscheel! I've merged your PR and released a new update. It should download the next time you open the app.

@mark-pictor-csec Try opening the app and downloading the latest update, and see if the problem persists for you after that. :)

TimOliver avatar May 03 '22 02:05 TimOliver

No luck for me, same problem still happening. Updated it, uninstalled/reinstalled using brew, same behavior as before...

I see that someone created another similar issue, I will keep an eye there https://github.com/steve228uk/YouTube-Music/issues/165

evsasse avatar May 03 '22 11:05 evsasse

@evsasse Uh. Whoops. Try downloading the release directly from GitHub and give that one a try. I haven't implemented automated releases to Brew yet. 😅

TimOliver avatar May 03 '22 12:05 TimOliver

I haven't implemented automated releases to Brew yet. 😅

But the "Check for updates" works, right? I am able to get 1.3.2, even though I installed with brew originally 👍.

Try downloading the release directly from GitHub and give that one a try.

Uninstalled from brew, and tried that just now... Still no luck :/

Navigation/search/etc works fine. But when I click to start playing something, it keeps loading forever, doesnt show the "bar" at the bottom.

Screen Shot 2022-05-03 at 10 28 23

evsasse avatar May 03 '22 13:05 evsasse

I was able to update to 1.3.2 from within the app, but I still can't play music.

mark-pictor-csec avatar May 03 '22 14:05 mark-pictor-csec

I’m thinking we might have to add code to force-unregister the service workers that are already installed for people. I’ll make an update for that asap.

On Tue, May 3, 2022 at 9:19 AM mark-pictor-csec @.***> wrote:

I was able to update to 1.3.2 from within the app, but I still can't play music.

— Reply to this email directly, view it on GitHub https://github.com/steve228uk/YouTube-Music/issues/163#issuecomment-1116155787, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABTUFWV6U4K4HQHNXSLDTTVIEYWTANCNFSM5UWKNTCQ . You are receiving this because you were mentioned.Message ID: @.***>

jscheel avatar May 03 '22 22:05 jscheel

Ok @TimOliver, I've added a new PR for unregistering service workers

jscheel avatar May 04 '22 14:05 jscheel

1.3.3 seems to have fixed it for me. Thanks @jscheel @TimOliver 🙇!

evsasse avatar May 06 '22 16:05 evsasse

Should Close this no, as I don't see this anymore as well

Raheemshah2809 avatar Jul 05 '22 00:07 Raheemshah2809

I have just discovered this app (v1.3.3). It is not working here (10.13.6), I have a blank screen and nothing more...

targyll avatar Feb 19 '23 00:02 targyll