Repository: vispy/vispy

Issue:
Apple M1 macOS 12 canvas is a quarter of window size 
I have found an issue on macos 12 with apple m1 - dont know if it exists on x64 macos - dont have one so cannot test it.

all test are done with the offical examples!

The issue seems to be that the canvas is not the specified size - it's a quarter of it 
This is with pyglet
<img width="912" alt="Untitled" src="https://user-images.githubusercontent.com/13086508/164896228-5f829153-4b5e-439b-8196-96efeee3ebb3.png">

pyglet scaled the whole canvas to to a quarter and also renders it at a quarter. Moving the qube works fine as you would expect just scaled down to a quarter

In contrast wx:

https://user-images.githubusercontent.com/13086508/164896545-086ae183-f87e-4934-b781-e3c296984bdd.mov

With wx the canvas is rendered a the correct resolution but only the lower left is quarter is visable. Moving the scene quarters the output to a quarter but the qube is now centered in frame - letting go of the mouse button goes back to the full canvas size with just the lower left quarter visable

The behavior continues with all of the other examples I tested




 


Discussion:
Could you please provide the output of running:

```bash
python -c "import vispy; print(vispy.sys_info())"
```

And can you test with PyQt5 please? Are you using conda or pip or something else?
images above are from conda miniforge3 env PyQt5 isn't possible on m1 at least from existing packages in conda miniforge3 and pip failes-  I tested PyQt6 which run without issues

Platform: macOS-12.3.1-arm64-arm-64bit
Python:   3.9.10 | packaged by conda-forge | (main, Feb  1 2022, 21:27:43)  [Clang 11.1.0 ]
NumPy:    1.21.6
Backend:  PyQt6
pyqt4:    None
pyqt5:    None
pyqt6:    ('PyQt6', '6.3.0', '6.3.0')
pyside:   None
pyside2:  None
pyside6:  None
pyglet:   pyglet 1.5.16
glfw:     None
sdl2:     None
wx:       wxPython 4.1.1
egl:      None
osmesa:   None
tkinter:  None
jupyter_rfb: None
_test:    None

GL version:  '2.1 Metal - 76.3'
MAX_TEXTURE_SIZE: 16384
Extensions: 'GL_ARB_color_buffer_float GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_instanced_arrays GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_provoking_vertex GL_ARB_seamless_cube_map GL_ARB_shader_objects GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shadow GL_ARB_shadow_ambient GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_transpose_matrix GL_ARB_vertex_array_bgra GL_ARB_vertex_blend GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_draw_buffers2 GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_multisample_blit_scaled GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture_array GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_EXT_texture_env_add GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod_bias GL_EXT_texture_rectangle GL_EXT_texture_shared_exponent GL_EXT_texture_sRGB GL_EXT_texture_sRGB_decode GL_EXT_timer_query GL_EXT_transform_feedback GL_EXT_vertex_array_bgra GL_APPLE_aux_depth_stencil GL_APPLE_client_storage GL_APPLE_element_array GL_APPLE_fence GL_APPLE_float_pixels GL_APPLE_flush_buffer_range GL_APPLE_flush_render GL_APPLE_packed_pixels GL_APPLE_pixel_buffer GL_APPLE_rgb_422 GL_APPLE_row_bytes GL_APPLE_specular_vector GL_APPLE_texture_range GL_APPLE_transform_hint GL_APPLE_vertex_array_object GL_APPLE_vertex_point_size GL_APPLE_vertex_program_evaluators GL_APPLE_ycbcr_422 GL_ATI_separate_stencil GL_ATI_texture_env_combine3 GL_ATI_texture_float GL_IBM_rasterpos_clip GL_NV_blend_square GL_NV_conditional_render GL_NV_depth_clamp GL_NV_fog_distance GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_light_max_exponent GL_NV_texgen_reflection GL_NV_texture_barrier GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_SGI_color_matrix GL_SGIS_generate_mipmap GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod '






python3.9 homebrew no virtual env exactly same beheavior. wx and pyglet have the same issues as above. Only difference is pyqt5. Just like pyqt6 working flawlessly.

Platform: macOS-12.3.1-arm64-arm-64bit
Python:   3.9.12 (main, Mar 26 2022, 15:44:31)  [Clang 13.1.6 (clang-1316.0.21.2)]
NumPy:    1.22.3
Backend:  PyQt5
pyqt4:    None
pyqt5:    ('PyQt5', '5.15.6', '5.15.2')
pyqt6:    None
pyside:   None
pyside2:  None
pyside6:  None
pyglet:   pyglet 1.5.23
glfw:     None
sdl2:     None
wx:       wxPython 4.1.1
egl:      None
osmesa:   None
tkinter:  None
jupyter_rfb: None
_test:    None

GL version:  '2.1 Metal - 76.3'
MAX_TEXTURE_SIZE: 16384
Extensions: 'GL_ARB_color_buffer_float GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_instanced_arrays GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_provoking_vertex GL_ARB_seamless_cube_map GL_ARB_shader_objects GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shadow GL_ARB_shadow_ambient GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_transpose_matrix GL_ARB_vertex_array_bgra GL_ARB_vertex_blend GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_draw_buffers2 GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_multisample_blit_scaled GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture_array GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_EXT_texture_env_add GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod_bias GL_EXT_texture_rectangle GL_EXT_texture_shared_exponent GL_EXT_texture_sRGB GL_EXT_texture_sRGB_decode GL_EXT_timer_query GL_EXT_transform_feedback GL_EXT_vertex_array_bgra GL_APPLE_aux_depth_stencil GL_APPLE_client_storage GL_APPLE_element_array GL_APPLE_fence GL_APPLE_float_pixels GL_APPLE_flush_buffer_range GL_APPLE_flush_render GL_APPLE_packed_pixels GL_APPLE_pixel_buffer GL_APPLE_rgb_422 GL_APPLE_row_bytes GL_APPLE_specular_vector GL_APPLE_texture_range GL_APPLE_transform_hint GL_APPLE_vertex_array_object GL_APPLE_vertex_point_size GL_APPLE_vertex_program_evaluators GL_APPLE_ycbcr_422 GL_ATI_separate_stencil GL_ATI_texture_env_combine3 GL_ATI_texture_float GL_IBM_rasterpos_clip GL_NV_blend_square GL_NV_conditional_render GL_NV_depth_clamp GL_NV_fog_distance GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_light_max_exponent GL_NV_texgen_reflection GL_NV_texture_barrier GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_SGI_color_matrix GL_SGIS_generate_mipmap GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod '
I wonder if this is like a HiDPI issue. But I'd be surprised if this is the first we're hearing of it. We had to do some upgrades/fixes to the Qt backends to make them work in these HiDPI cases (2x logical pixels versus physical pixels). I personally only ever use Qt-based and I don't have a mac. The fact that this is backend dependent seems like it isn't necessarily an OpenGL issue which is my biggest fear when dealing with Apple products.

I don't think any of the other @vispy/core developers have Macs either (M1 or not) so we'd have to find some people with Macs and test Wx or pyglet and see if this is a Mac thing or a M1 thing.
If someone tells me exactly what I need to run I'm happy to run it on my macOS 11 Intel mac. (And maybe even finally take the plunge and upgrade to 12!)
If you got the time just run official vispy examples
like this one 

https://vispy.org/gallery/scene/infinite_line.html#sphx-glr-gallery-scene-infinite-line-py

with a pyglet or wx backend
I don't know how to set the backend.
just put

`
import vispy;
vispy.app.use_app("wx"); // or vispy.app.use_app("pyglet")
`

in the first lines

also you would need pyglet or wx installed
I have an M1 mac (since a few months now). I can reproduce the error. Looking into it.

Resolving patch:
diff --git a/vispy/app/backends/_pyglet.py b/vispy/app/backends/_pyglet.py
--- a/vispy/app/backends/_pyglet.py
+++ b/vispy/app/backends/_pyglet.py
@@ -271,6 +271,12 @@ def _vispy_get_size(self):
         w, h = self.get_size()
         return w, h
 
+    def _vispy_get_physical_size(self):
+        if self._vispy_canvas is None:
+            return
+        w, h = self.get_framebuffer_size()
+        return w, h
+
     def _vispy_get_position(self):
         x, y = self.get_location()
         return x, y
diff --git a/vispy/app/backends/_wx.py b/vispy/app/backends/_wx.py
--- a/vispy/app/backends/_wx.py
+++ b/vispy/app/backends/_wx.py
@@ -376,6 +376,11 @@ def _vispy_get_size(self):
         w, h = self.GetClientSize()
         return w, h
 
+    def _vispy_get_physical_size(self):
+        w, h = self.GetClientSize()
+        ratio = self.GetContentScaleFactor()
+        return int(w * ratio), int(h * ratio)
+
     def _vispy_get_position(self):
         if self._vispy_canvas is None:
             return


Test patch: