Skip to content

Commit

Permalink
Limit the maximum zoom level
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
kepstin committed Oct 31, 2024
1 parent ef37918 commit 08644f9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bbb_presentation_video/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 08644f9

Please sign in to comment.