From 08644f95f52ea02a47f4922a0f102e056166bb46 Mon Sep 17 00:00:00 2001 From: Calvin Walton Date: Thu, 31 Oct 2024 13:12:05 -0400 Subject: [PATCH] Limit the maximum zoom level The BigBlueButton client (in current versions) doesn't allow zooming in further than 400% (i.e. 1/4 of document width). However, there are occasionally glitches which can cause a higher zoom level to be reported - sometimes, *extremely* high (an issue was reported where the slide scale ended up being 108000%). This can cause issues in the rendering. For example, if a shape with text is being drawn, the required font size might exceed the maximum limits of the freetype text rasterizer. (With newer versions of cairo, this error is recoverable, but with older versions like used on Ubuntu 20.04 the error will crash the video generation tool.) Apply a safety limit on the zoom level so that it does not exceed 800% (i.e. 1/16 of document width). --- bbb_presentation_video/events/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bbb_presentation_video/events/__init__.py b/bbb_presentation_video/events/__init__.py index 86a2b90..04b9211 100644 --- a/bbb_presentation_video/events/__init__.py +++ b/bbb_presentation_video/events/__init__.py @@ -131,16 +131,24 @@ def parse_pan_zoom( width_ratio = xml_subelement(element, name, "widthRatio") height_ratio = xml_subelement(element, name, "heightRatio") + + # Some BBB versions can produce invalid NaN ratios which can't be parsed as floats if width_ratio == "NaN" or height_ratio == "NaN": event["zoom"] = Size(1.0, 1.0) else: event["zoom"] = Size(float(width_ratio) / 100, float(height_ratio) / 100) + # Workaround a bug where BBB can return a width or height ratio of 0, # which is nonsensical and causes divide-by-zero errors. # It can also return values less than zero, I dunno what's up with that. if event["zoom"].width <= 0 or event["zoom"].height <= 0: event["zoom"] = Size(1.0, 1.0) + # The max zoom permitted in the BBB client is 400% (i.e. show 1/4 of the width of the slide) + # Apply a hard limit at 800% to prevent processing errors + if event["zoom"].width < 0.125: + event["zoom"] = Size(0.125, event["zoom"].height * (0.125 / event["zoom"].height)) + pod_id = xml_subelement_opt(element, "podId") event["pod_id"] = pod_id if pod_id is not None else DEFAULT_PRESENTATION_POD