Skip to content

Conversation

@andyzzhao
Copy link
Contributor

@andyzzhao andyzzhao commented Oct 31, 2025

Problem

There are two issues with exporting images:

  1. There are some large insights (tables with thousands of rows or giant rows) that eat up memory when we try to screenshot them.

  2. In addition, the thread running the screenshot sometimes continues even after the top level coroutine times out, resulting in 100% memory usage after the temporal workflow has completed. Temporal is able to retry activities when we the pods get OOM killed, but if there are too many OOMs in a single workflow, the retries get exhausted.

image

related convo: https://posthog.slack.com/archives/C09BDQLM8KA/p1761925099100499

Changes

Address, the first issue directly by limiting the number of pixels we screenshot. This should indirectly help the second issue, as the screenshot shouldn't run as long with fewer pixels to capture.

How did you test this code?

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Locally. Verified that a png export is shorter with the new setting.

Changelog: (features only) Is this feature complete?

@posthog-bot posthog-bot requested a review from a team October 31, 2025 17:26
@andyzzhao andyzzhao changed the title Andyzzhao/cap png export height to prevent oom Oct 31, 2025
"""
)

if max_height_pixels and height > max_height_pixels:
Copy link
Contributor Author

@andyzzhao andyzzhao Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caveat with this approach is that chrome still has to load the entire table, but at least it doesn't have to screenshot the entire table.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. ee/tasks/subscriptions/subscription_utils.py, line 122 (link)

    logic: Celery task path doesn't pass height limit, so generate_assets() (used by some subscriptions and Slack sharing) won't get OOM protection that generate_assets_async() has

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants