PG1204 opened a new issue, #8992:
URL: https://github.com/apache/texera/issues/8992

   ### Task Summary
   
   `_html_to_image_bytes` renders Plotly figures by calling `pio.to_image`, 
which starts a Chromium subprocess through kaleido. This runs once per row on 
figure JSON taken from the cell, with no bound on the figure's size or 
complexity.
   
   ### Context
   
   The Plotly branch of `_html_to_image_bytes` (`HuggingFaceCodegenBase.scala`, 
lines 1015-1040) parses the chart out of the cell's HTML and renders it:
   
       data = json.loads(data_json)
       layout = json.loads(layout_json) if layout_json else {}
       fig = go.Figure(data=data, layout=layout)
       return pio.to_image(fig, format="png", width=800, height=600)
   
   Two properties make this expensive. `pio.to_image` launches a headless 
browser via kaleido, so each row that reaches this branch pays process startup 
plus render time. And `data_json` is whatever the cell contained: the number of 
traces, the points per trace and the nesting depth are all unbounded, so render 
cost scales with content the operator did not produce.
   
   Reaching the branch needs only a cell whose value looks like HTML containing 
`Plotly.`, which `_read_binary_value` routes here. A table of such rows 
therefore drives one browser render per row, serially, with no ceiling and no 
timeout.
   
   Related to #8962: that issue caps the cell before parsing, which bounds the 
input to this branch but does not address the per-row subprocess or the 
figure's complexity.
   
   ### Proposed change
   
   Bound this path rather than removing it. Reasonable options, not mutually 
exclusive:
   
   - cap the parsed figure before rendering — total points, trace count, or the 
length of `data_json`, and fall back to the existing `ValueError` when exceeded
   - reuse a single kaleido process across rows instead of paying startup each 
time
   - gate the branch behind an operator property so rendering is opt-in rather 
than implied by the cell's content
   
   Worth a maintainer's view on which is wanted before implementing, since the 
third changes behaviour for anyone relying on it today.
   
   ### Required test
   
   Add a test asserting the generated Python applies the chosen bound before 
`pio.to_image`, and that an oversized or overly complex figure takes the 
fallback path instead of rendering.
   
   
   ### Task Type
   
   - [ ] Refactor / Cleanup
   - [ ] DevOps / Deployment / CI
   - [ ] Testing / QA
   - [ ] Documentation
   - [x] Performance
   - [ ] Other


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to