-
Notifications
You must be signed in to change notification settings - Fork 11
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
YouTube Music freezing the webviews #35
Comments
Hi @Priyanshu-CODERX , thanks for the report. I just read and not everything you mentioned, but I tested The following issues are I previously noticed and similar the issue that you mentioned. Maybe thier related and maybe issues are already fixed in the latest version.
Additionally, please paying attention that it is impossible to play multiple media with multiple WebView. If you playing media with WebView, other WebView instance's media will be paused. What plugin version are you currently using ? Currently, I couldn't check the issue for app crash and media still playing even if close app. If it is possible, it is preferble to attach |
Hi @TLabAltoh, thank you for your prompt response. I am currently using version 1.0.1 of the plugin. The pages are loading correctly, including YouTube and other sites. However, when I visit YouTube Music and play a song, the entire WebView freezes. Interestingly, no errors are being logged in logcat. For YouTube, it is expected behavior that when multiple WebView instances are open, playing media in one instance pauses playback in the others. However, with YouTube Music, the website completely freezes not after media starts playing but when I try to search for something else through the search bar. Even attempting to destroy the frozen instance doesn’t stop the playback, and this causes every other WebView instance to freeze as well. Any new instance that I try to open after this issue, the page remains completely blank. Previously, there was an issue where destroying a WebView instance while a YouTube video was playing caused the app to crash. My workaround for that was to redirect the WebView to a static page before destroying the instance. This solution worked well for other media players. However, with YouTube Music, the WebView does not even load the static page, making this workaround ineffective. I couldn’t find anything unusual in the logcat to indicate why the freeze and crash occurred, but I will recheck it. Meanwhile, here’s how you can reproduce the issue:
When you do this, all the WebView instances freeze. If you try to use other WebView instances or create new ones, you’ll notice the entire system freezes. In some cases, it crashes. When a crash occurs, the media continues to play quite abruptly. I am attaching a couple of recordings for your reference. Also, I would like to know if there is a better way to destroy these instances? cos currently I am just using Destroy() any cleanups that I would have to do? |
Thanks for the details ... I'll check them again ! |
This is just a progress report, but I was able to reproduce the error (currently, I only checked https://youtu.be/yP_5Aydb-sg yet) ... I think this issue is related to the In this video, I was asked "Can you leave this site? Changes you have made may not be saved. (cancel / leave the page)". It didn't show up in the (oculus/meta) quest's screen-20250103-042538.mp4Maybe the above problem can't be solved from my side because it's an OS layer problem. So I suggest to use Please note that changing the browser engine from Please see here for replace browser engine from In the meantime, after a little time, I will check the other issue (https://youtu.be/G_b8o4EpKOM). But please don't hesitate to ask me about replacing the browser engine from
↑ using |
Hey, thanks for the update! I tried using GeckoView as you suggested, and it resolved the issue with destroying the YouTube Music instance—there are no longer any problems when I do so. However, I encountered another issue. After playing music on YouTube Music and performing a search through the search bar, a popup appears as expected when leaving the site. But when I click on any of the buttons in the popup, the app crashes. I’m attaching the crash log for your reference. Let me know if you need additional details or further testing!
|
Also, I cannot seem to view youtube video on fullscreen and this error is popping up
|
Please update Also, full screen is not supported at the moment in See here for details. This developer had the same problem and discussed it with the I know it is inconvenient that there is no complete solution. I'm just trying to figure out what to do about it ... |
Hi! Thanks for your help on this. 😊 I’ll update to version 1.0.3. I also wanted to ask how to inject JavaScript into WebView. I tried using EvaluateJS, but nothing seemed to happen. My goal is to block popups from appearing on these websites so that I can use WebView without any crashes. Below is the code that blocks the popups from happening.
|
I see, that's the way to do it. I have not tested the code on my environment, so it is not sure, but maybe removing the commentout will make it work. PS: I'll check myself later. |
I tested on my environment (only my Android phone, it is not Oculus Quest but based on the same OS so it is enough to test) and faced failure. And this problem seems to be caused by my native plugin problem, so I updated the plugin from |
Hey! mate thanks for your support. I tried the package and I am currently getting this error
I tried deleting it but as it's a part of the package itself it keeps coming back. |
Thanks for the report ... Currently investigating. Could you try restarting the editor and reinstalling the package? I have not been able to reproduce the error and do not know the cause of the error ... Your package's commit id is certainly latest version. So maybe there happened to be some git error or conflict of script file's metadata (not sure) ? |
Maybe this (form A) or this (form B) will help ?
|
Hi! I tried the suggested solutions, but unfortunately, they didn’t resolve the issue. I plan to explore a few more approaches to see if they work. In the meantime, I deleted the script and built the app again, but the JavaScript code still doesn’t seem to execute. I also tested it with your sample, and the issue persists there as well. Currently, I’m using the BrowserContainer to access the EvaluateJS() function. This function is invoked whenever the enter or search button is pressed, utilizing the OnEnter event from the SearchBar script. However, the same problem continues. Interestingly, it worked temporarily when I tried this approach a few days ago with the update you provided. However, after building the app a second time, the issue reappeared. It'd be great if you could take a look at that Thanks |
I re-tested and noticed that Therefor, I have added C# using UnityEngine;
namespace TLab.WebView.Sample
{
public class JSSnippets : MonoBehaviour
{
[SerializeField] private BrowserContainer m_container;
public void DisableBeforeUnload()
{
var js = Resources.Load<TextAsset>("TLab/WebView/Samples/Scripts/JS/disable-beforunload")?.ToString();
m_container.browser.EvaluateJS(js);
}
}
} javascript // disable-beforeunload.txt
const originalAddEventListener = window.addEventListener;
window.addEventListener = function (type, listener, options) {
if (type === 'beforeunload') {
console.warn("Blocked a 'beforeunload' listener from being added.");
return;
}
originalAddEventListener.call(this, type, listener, options);
}; |
Hey mate, thanks a ton for all your help! The scripts are now executing properly, and I also managed to resolve the conflict error. It turned out that there were a few duplicate files in the project causing the issue. Deleting the entire package along with those duplicates fixed it. However, there's still one issue remaining: the "GoForward" functionality isn't working for the webviews, even though the "GoBack" feature works perfectly. |
Thanks for reporting, it is a related plugin bug. So I released fixed version just now but please note that this update didn't updated package version code (treated as tiny update). Please update |
Ah, awesome, thanks! :) Would it possible to add an event callback that gets invoked when any input field is clicked? The goal is to make the keyboard appear only when an input field is selected. |
It is possible to switch keybord's active state via html input's focus event, but it is with some limmitation. Here is an example and this feature has implemented on this sample repositly. C# using UnityEngine;
using UnityEngine.EventSystems;
using TLab.VKeyborad;
namespace TLab.WebView.Sample
{
public class FocusInOutInteractionSample : MonoBehaviour, IPointerDownHandler
{
[SerializeField] private SearchBar m_searchBar;
[SerializeField] private BaseInputField m_inputField;
[SerializeField] private BrowserContainer m_container;
public void OnPageFinish(string url)
{
var js = JSUtil.ToVariable("go", gameObject.name) + JSUtil.ToVariable("method", nameof(OnMessage));
js += Resources.Load<TextAsset>("TLab/WebView/Samples/Scripts/JS/focus-in-out-interaction")?.ToString();
m_container.browser.EvaluateJS(js);
}
public void OnMessage(string message)
{
Debug.Log("OnMessage: " + message);
switch (message)
{
case "Focusin":
m_inputField.OnFocus(true);
break;
case "Focusout":
m_inputField.OnFocus(false);
break;
}
}
public void OnPointerDown(PointerEventData eventData) => m_searchBar.OnFocus(false);
}
} javascript function searchShadowRoot(node, roots) {
if (node == null) {
return;
}
if (node.shadowRoot != undefined && node.shadowRoot != null) {
roots.push(node.shadowRoot);
searchShadowRoot(node.shadowRoot, roots);
}
for (var i = 0; i < node.childNodes.length; i++) {
searchShadowRoot(node.childNodes[i], roots);
}
}
function getAllRoot() {
var roots = [document];
searchShadowRoot(document, roots);
return roots;
}
var roots = getAllRoot();
function focusin (e) {
const target = e.target;
if (target.tagName == 'INPUT' || target.tagName == 'TEXTAREA') {
window.tlab.unitySendMessage(go, method, 'Focusin');
}
}
function focusout (e) {
const target = e.target;
if (target.tagName == 'INPUT' || target.tagName == 'TEXTAREA') {
window.tlab.unitySendMessage(go, method, 'Focusout');
}
}
for (var i = 0; i < roots.length; i++) {
roots[i].removeEventListener('focusin', focusin);
roots[i].removeEventListener('focusout', focusout);
roots[i].addEventListener('focusin', focusin);
roots[i].addEventListener('focusout', focusout);
} This approach didn't work on some website because it's impossible to add event listener to iframe's html document if iframe content's server doesn't allow crossorigin access. So above example will work on most of website, but won't work on only some iframe content. other solutionOculus Quest can use the system keyboard on unity and also works on the WebView doesn't have feature for handling html element's event other than javascript. So I am still considering more efficient way but this is only way I came up with ... |
Thanks mate for the suggestions, I have switched to system keyboard for now but I will be experimenting with the other approach as well. Thanks for all the help :) |
I’ve integrated the TLabWebView plugin with the Meta XR SDK, but I’m encountering an issue with YouTube Music. When I open the YouTube Music website, it freezes the entire webview system. After that, no other URLs can be loaded, even if I destroy the webview instance at runtime. However, the music continues playing in the background. If I try to instantiate a new webview, it fails to load, and this sometimes leads to the app crashing. Even when the app doesn’t crash, the music persists in the background, and closing the app doesn’t stop it. I ultimately have to restart the headset to resolve the issue.
Any solution to this would be highly appreciated.
Thanks
The text was updated successfully, but these errors were encountered: