A quick fix is available for Nexus 6 users experiencing lag issue with the YouTube app. According to users, the video freezes while playing the video and scrolling the comments at the same time. The issue cropped up only after the Android Marshmallow update and the problem is not linked to the YouTube app.
In their response to the issue, through a recent AMA (Ask Me Anything) session over Reddit, the Android engineering team said: "We are looking into this. We did notice some jank while scrolling comments that are being loaded for the very first time during YouTube video playback on Nexus 6 running Android M."
"The jank does seem to improve when forcing GPU composition. YouTube on Android 6.0 uses SurfaceViews for video playback because it consumes less power than using TextureViews. Forcing GPU composition improves comment scrolling smoothness at the cost of power. Stay tuned," added the team.
The team further suggests that enabling the "Disable HW Overlays" setting fixes the YouTube lag. To enable this feature, head over to the Developer Options and from there turn on the Disable HW Overlays option. To get the Developer Options, head over to Settings, then About Device; from there, scroll down to the Build Number and tap on the build number seven times.
Disabling HW Overlays results in consuming more power and it is supposed to be used for debugging certain kinds of media applications, explain folks at XDA. But there is a workaround for this: use apps such as Tasker with the Secure Settings plugin to automate toggling Disable HW overlays option when using the YouTube app.