{"record":{"id":"d3b96360dbadb322","repo":"Unity-Technologies/UnityCsReference","slug":"value-cannot-be-null-parameter-playmodeviews","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'playModeViews')","messagePattern":"Value cannot be null\\. \\(Parameter 'playModeViews'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/PerformanceTools/FrameDebugger.cs","lineNumber":302,"sourceCode":"        private void HandleEnablingFrameDebugger()\n        {\n            if (Event.current.type != EventType.Repaint)\n                return;\n\n            m_EnablingWaitCounter++;\n            if (m_EnablingWaitCounter == k_NeedToRepaintFrames)\n            {\n                FrameDebuggerEvent[] descs = FrameDebuggerUtility.GetFrameEvents();\n                m_TreeView = new FrameDebuggerTreeView(descs, m_TreeViewState, this, new Rect(50, 50, 500, 100));\n                m_FrameEventsHash = FrameDebuggerUtility.eventsHash;\n                ChangeFrameEventLimit(FrameDebuggerUtility.count);\n            }\n        }\n\n        int GetAllAvailablePlayModeViews(ref List<PlayModeView> playModeViews)\n        {\n            if (playModeViews == null)\n                throw new ArgumentNullException(nameof(playModeViews));\n\n            var mainPlaymodeView = PlayModeView.GetMainPlayModeView();\n            if (mainPlaymodeView != null)\n                playModeViews.Add(mainPlaymodeView);\n\n            foreach (var playModeView in PlayModeView.GetAllPlayModeViewWindows())\n            {\n                if (playModeView != null && !playModeViews.Contains(playModeView))\n                    playModeViews.Add(playModeView);\n            }\n\n            return playModeViews.Count;\n        }\n\n        internal bool GetFirstAvailablePlayModeView(out PlayModeView playModeView)\n        {\n            playModeView = null;\n","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/PerformanceTools/FrameDebugger.cs#L284-L320","documentation":"Thrown by FrameDebugger.GetAllAvailablePlayModeViews when the playModeViews list passed by reference is null. The method populates the caller-supplied list with all open PlayModeView windows (main view plus any additional windows). It requires a pre-allocated list because it uses the list as both input (to avoid duplicates) and output buffer.","triggerScenarios":"Calling GetAllAvailablePlayModeViews(ref someList) where someList is null. This is an internal method used during frame debugger enable/refresh cycles, so the error surfaces when the frame debugger's tree view refresh encounters an uninitialized list reference.","commonSituations":"Frame debugger window initialization; editor extension code that queries play mode views; refactoring that changes the list initialization order so the method is called before the list field is constructed.","solutions":["Initialize the list before passing it: var views = new List<PlayModeView>(); GetAllAvailablePlayModeViews(ref views);","If this is a field, ensure it is assigned in the constructor or field initializer before any method that calls GetAllAvailablePlayModeViews.","Add a null-coalescing initializer at the call site: playModeViews ??= new List<PlayModeView>();"],"exampleFix":"// before\nGetAllAvailablePlayModeViews(ref m_Views); // m_Views is null\n\n// after\nm_Views ??= new List<PlayModeView>();\nGetAllAvailablePlayModeViews(ref m_Views);","handlingStrategy":"validation","validationCode":"playModeViews ??= new List<PlayModeView>();\nGetAllAvailablePlayModeViews(ref playModeViews);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Initialize list fields in constructors or field initializers before methods that consume them.","Use null-coalescing assignment (??=) at call sites for ref-list parameters.","Establish a convention: never pass null collections to ref parameters."],"tags":["unity-editor","frame-debugger","playmode","null-reference","argument-validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}