Search Issue Tracker
Won't Fix
Votes
1
Found in [Package]
services-wire-1.3.0
Issue ID
MTTB-1057
Regression
No
Uncaught TypeError: Cannot read properties of undefined is thrown when the tab is inactive for several minutes
How to reproduce:
1. Open the “authorization“ project
2. On the Menu, select File → Build and Run
4. After the project builds, change to a different browser tab
5. Wait for 5 minutes
6. Press “ctrl+shift+j“ and observe the Console
Expected result: No errors are thrown
Actual result: An error is thrown
Reproducible with: 2021.3.38f1, 2022.3.30f1, 6000.0.3f1
Reproducible on: Windows 10, Windows 11 (user’s device)
Not reproducible on: No other environment tested
Error: Uncaught TypeError: Cannot read properties of undefined (reading 'readyState')
Note: If the issue does not reproduce rebuild the project
Comments (1)
-
Bliggfang
Aug 03, 2025 08:45
I just wanted to add that I’ve managed to work around this issue by implementing a custom post-build script that decompresses the play.framework.js.unityweb file, replaces all ===null and !==null checks with the more resilient ==null and !=null (to also catch undefined), and then recompresses the file before deployment.
Here’s the script I’m using:
(see full code snippet below)While this resolves the crash on our end, I have no idea what unintended side effects this might have long-term. It’s more of a last resort than a proper solution.
What really surprises me is that such a critical and easily reproducible issue - affecting any WebGL game using Unity Push Messages, Relay, or WebSocket-based networking - has not been addressed officially yet. In its current state, Unity WebGL builds relying on persistent WebSocket connections are unreliable in production. Even switching browser tabs or normal gameplay can eventually trigger this crash.
Hopefully this workaround helps others until a proper fix is implemented.
Code:
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using System.IO;
using System.IO.Compression;public class FrameworkPatchPostBuild : IPostprocessBuildWithReport
{
public int callbackOrder => 0;public void OnPostprocessBuild(BuildReport report)
{
// ensure the build target is WebGL
if (report.summary.platform != BuildTarget.WebGL)
return;// path to the play.framework.js.unityweb file
string buildPath = report.summary.outputPath + "/Build";
string frameworkPath = buildPath + "/play.framework.js.unityweb";if (!File.Exists(frameworkPath))
{
UnityEngine.Debug.LogWarning("[PostBuildPatch] play.framework.js.unityweb not found.");
UnityEngine.Debug.LogWarning(buildPath);
UnityEngine.Debug.LogWarning(frameworkPath);
return;
}// temporary path for the extracted file
string tempExtractedPath = Path.Combine(buildPath, "play.framework.js");// decompress the .gz file
File.Move(frameworkPath, frameworkPath + ".gz");
DecompressGzip(frameworkPath + ".gz", tempExtractedPath);// apply patch to the extracted file
string content = File.ReadAllText(tempExtractedPath);
string patchedContent = content.Replace("!==null", "!=null").Replace("===null", "==null");
File.WriteAllText(tempExtractedPath, patchedContent);// recompress the patched file
CompressGzip(tempExtractedPath, frameworkPath);// clean up temporary files
File.Delete(tempExtractedPath);
File.Delete(frameworkPath + ".gz");UnityEngine.Debug.Log("[PostBuildPatch] play.framework.js.unityweb was patched and restored.");
}private void DecompressGzip(string gzipPath, string outputPath)
{
using (FileStream originalFileStream = new FileStream(gzipPath, FileMode.Open, FileAccess.Read))
using (FileStream decompressedFileStream = new FileStream(outputPath, FileMode.Create))
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
{
decompressionStream.CopyTo(decompressedFileStream);
}
}private void CompressGzip(string inputPath, string gzipPath)
{
using (FileStream originalFileStream = new FileStream(inputPath, FileMode.Open, FileAccess.Read))
using (FileStream compressedFileStream = new FileStream(gzipPath, FileMode.Create))
using (GZipStream compressionStream = new GZipStream(compressedFileStream, CompressionLevel.Optimal))
{
originalFileStream.CopyTo(compressionStream);
}
}
}
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Text overlap and is unreadable in Inspector > Terrain Paint Texture after creating new Terrain Layer
- Event "XRInputSubsystem.trackingOriginUpdated" triggers twice when recentering the view
- UITK TextField value is overwritten incorrectly by the converter result when Binding Mode is set to "To Source"
- Out of memory crash when selecting more than 80000 Assets simultaneously
- Test Runner fails to create a script in the active path when selecting a file as the active path
Resolution Note:
There are no fixes planned for this Bug