Skip to content

Commit

Permalink
Merge pull request #2090 from pupil-labs/glfw-selective-error-reporting
Browse files Browse the repository at this point in the history
Selective glfw error reporting #2
  • Loading branch information
papr authored Jan 21, 2021
2 parents 31dd08a + 5e5b88e commit 91d2173
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 26 deletions.
3 changes: 1 addition & 2 deletions pupil_src/launchables/eye.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ def toggle_general_settings(collapsed):
general_settings.collapsed = collapsed

# Initialize glfw
with GLFWErrorReporting.glfw_init():
glfw.init()
glfw.init()
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
if hide_ui:
glfw.window_hint(glfw.VISIBLE, 0) # hide window
Expand Down
6 changes: 2 additions & 4 deletions pupil_src/launchables/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ def get_dt():

window_name = f"Pupil Player: {meta_info.recording_name} - {rec_dir}"

with GLFWErrorReporting.glfw_init():
glfw.init()
glfw.init()
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
main_window = glfw.create_window(width, height, window_name, None, None)
window_position_manager = gl_utils.WindowPositionManager()
Expand Down Expand Up @@ -859,8 +858,7 @@ def on_drop(window, paths):
session_settings.clear()
w, h = session_settings.get("window_size", (1280, 720))

with GLFWErrorReporting.glfw_init():
glfw.init()
glfw.init()
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
glfw.window_hint(glfw.RESIZABLE, 0)
window = glfw.create_window(w, h, "Pupil Player", None, None)
Expand Down
3 changes: 1 addition & 2 deletions pupil_src/launchables/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,7 @@ def handle_notifications(noti):
)

# window and gl setup
with GLFWErrorReporting.glfw_init():
glfw.init()
glfw.init()
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
if hide_ui:
glfw.window_hint(glfw.VISIBLE, 0) # hide window
Expand Down
21 changes: 9 additions & 12 deletions pupil_src/shared_modules/gl_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,6 @@ def get_window_title_bar_rect(window) -> _Rectangle:


class GLFWErrorReporting:
@classmethod
@contextlib.contextmanager
def glfw_init(cls):
ignore = [
# GLFWError: (65544) b'Cocoa: Failed to find service port for display'
# This happens on macOS Big Sur running on Apple Silicone hardware
65544,
]
with cls.error_code_handling(ignore=tuple(ignore)):
yield

@classmethod
@contextlib.contextmanager
def error_code_handling(
Expand Down Expand Up @@ -383,7 +372,15 @@ def set_default(cls):

@staticmethod
def __default_error_reporting() -> _GLFWErrorReportingDict:
return {None: "raise"}
ignore = [
# GLFWError: (65544) b'Cocoa: Failed to find service port for display'
# This happens on macOS Big Sur running on Apple Silicone hardware
65544,
]
return {
None: "raise",
**{code: "log" for code in ignore},
}


GLFWErrorReporting.set_default()
3 changes: 1 addition & 2 deletions pupil_src/shared_modules/head_pose_tracker/ui/gl_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ def _init_trackball():
return trackball

def _glfw_init(self):
with GLFWErrorReporting.glfw_init():
glfw.init()
glfw.init()
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
window = glfw.create_window(
640,
Expand Down
3 changes: 1 addition & 2 deletions pupil_src/shared_modules/service_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def __init__(

self.texture = np.zeros((1, 1, 3), dtype=np.uint8) + 128

with GLFWErrorReporting.glfw_init():
glfw.init()
glfw.init()
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
if g_pool.hide_ui:
glfw.window_hint(glfw.VISIBLE, 0) # hide window
Expand Down
3 changes: 1 addition & 2 deletions pupil_src/shared_modules/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ def open_window(self):

# get glfw started
if self.run_independently:
with GLFWErrorReporting.glfw_init():
glfw.init()
glfw.init()
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
self.window = glfw.create_window(
self.window_size[0], self.window_size[1], self.name, None, None
Expand Down

0 comments on commit 91d2173

Please sign in to comment.