SetResolution doesn't work on Android

EDIT: I’ve confirmed this is 100% a bug with 5.3.5p2 as the exact same project works in 5.3.4p4.

Create a blank unity project. Attach a new script to the main camera with the following code in the Start() function:

Screen.SetResolution (1280, 720, true);

Deploy to Android device and Unity reports the following:

06-08 15:12:36.267  8965  8979 D Unity   : [EGL] Using protected surface (EGL_PROTECTED_CONTENT_EXT)
06-08 15:12:36.269  8965  8979 E Unity   : [EGL] Failed to create protected window surface: EGL_BAD_ATTRIBUTE: An unrecognized attribute or attribute value was passed in the attribute list.
06-08 15:12:36.269  8965  8979 E Unity   :
06-08 15:12:36.269  8965  8979 E Unity   : (Filename: ./Runtime/GfxDevice/egl/WindowContextEGL.cpp Line: 123)
06-08 15:12:36.269  8965  8979 E Unity   :
06-08 15:12:36.272  8965  8979 D Unity   : ANativeWindow: (1920/1080) RequestedResolution: (1280/720) EGLSurface: (1280/720)
06-08 15:12:36.282  8965  8995 D Unity   : Requested framebuffer: resolution[1280x720], rgba[8/8/8/8], depth+stencil[on], samples[1]
06-08 15:12:36.282  8965  8995 D Unity   : Created framebuffer: resolution[1280x720], rgba[8/8/8/8], depth+stencil[24/8], samples[0]
06-08 15:12:36.287   235   235 E SurfaceFlinger: rejecting buffer: bufWidth=1280, bufHeight=720, front.active.{w=1920, h=1080}
06-08 15:12:36.304   235   235 E SurfaceFlinger: rejecting buffer: bufWidth=1280, bufHeight=720, front.active.{w=1920, h=1080}
06-08 15:12:36.321   235   235 E SurfaceFlinger: rejecting buffer: bufWidth=1280, bufHeight=720, front.active.{w=1920, h=1080}

Then nothing is rendered to screen after this.

I’m on version 5.3.5p2.

Any help would be greatly appreciated.

Alex

We used it on 5.3.4p2 to force Galaxy Tab S2 to render at full res and it worked.
Did you tried it on multiple devices?

I received a report from user with LG V10, that the screen was black and nothing happened after the Unity splash. I couldn’t get logs and could not reproduce it myself.

I reduce the resolution to Full-HD on the QHD devices, such as LG V10. This problem was (at least) in 5.3.5p2 and 5.3.5p3. When I downgraded to 5.3.5f1, it worked. Might be related, but might not as well.

Then again on my wifes Galaxy S6 it worked, and it is also a QHD device. My Nexus 6P I couldn’t test because I managed to break it just the other day. :frowning:

Could you verify with 5.3.5f1 if it works there? If it does, it’s likely the same problem I had. Have you submitted a bug report?

I saw a bug report where someone else had the exact same problem but I can’t seem to find it anymore so I’ve submitted one anyway. @r-pedra , it works in 5.3.4 versions, this is specifically the latest patched version.

Did you try 5.3.5f1 if it works for you? It did for me, patches did not.

Apparently the new patch 5.3.5p4 fixes this issue:

  • (802824) - Android: Fixed the issue of game freezing when changing resolution with Screen.SetResolution.