microsoft / microsoft/BotFramework-WebChat
Parsing base64 content causes maximum call stack size exceeded error
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 1.6k
- Avg merge
- 22h 58m
- Merged PRs (30d)
- 2
Description
Is it an issue related to Adaptive Cards?
No
Is this an accessibility issue?
No
What version of Web Chat are you using?
Unrelated
Which distribution are you using Web Chat from?
Bundle (webchat.js)
Which hosting environment does this issue primarily affect?
Web apps
Which browsers and platforms do the issue happened?
No response
Which area does this issue affect?
Attachment: Other rich cards
What is the public URL for the website?
No response
Please describe the bug
D365 conversation control hosts up to 10 webchat control instances at the same time.
When rendering multiple large attachments on multiple webchat control instances at the same time. the error below could be generated intermittently.
The error is thrown at the function:
https://ersuolocaldev.blob.core.windows.net/share/regex_parse_error.png
"stack":"RangeError: Maximum call stack size exceeded\n at RegExp.exec ()\n at u (https://oc-cdn-public-eur.azureedge.net/convcontrol/lib/webchat.js:2:2300840)\n/n) at t.default (https://oc-cdn-public-eur.azureedge.net/convcontrol/lib/webchat.js:2:2299659)\n/n) at u (https://oc-cdn-public-eur.azureedge.net/convcontrol/lib/webchat.js:2:1946002)\n/n) at Xi (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4489600)\n at xa (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4535646)\n at wl (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4528406)\n at Sl (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4528331)\n at fl (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4525354)\n at https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4477009","message":"Maximum call stack size exceeded"},
Do you see any errors in console log?
"stack":"RangeError: Maximum call stack size exceeded\n at RegExp.exec (<anonymous>)\n at u (https://oc-cdn-public-eur.azureedge.net/convcontrol/lib/webchat.js:2:2300840)\n at t.default (https://oc-cdn-public-eur.azureedge.net/convcontrol/lib/webchat.js:2:2299659)\n at u (https://oc-cdn-public-eur.azureedge.net/convcontrol/lib/webchat.js:2:1946002)\n at Xi (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4489600)\n at xa (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4535646)\n at wl (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4528406)\n at Sl (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4528331)\n at fl (https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4525354)\n at https://oc-cdn-public-eur.azureedge.net/convcontrol/Scripts/vendors.js?ver=3281cde91656f30c4a62:2:4477009","message":"Maximum call stack size exceeded"},
How to reproduce the issue?
- open multiple webchat control instances and attempted to render large attachments
- quickly refresh the components
- intermittently the rendering error could happen. The memory limitation seems also play a role there.
What do you expect?
From D365 OC conversation control, previously, we may directly pass the base64 content to webchat control to render at this logic had not been changed for years. Starting Oct, multiple VIP customers started report the rendering issue of the attachments. The fix we were providing is always convert the base64 content to blob before sending to webchat control.
No immediate mitigation needed from webchat control now.
What actually happened?
The regex expression execution seems used a lot of computing power when parsing the large attachments simultaneously. When the error mentioned above happens, the browser become lagging and nonresponsive.
Do you have any screenshots or recordings to repro the issue?
https://ersuolocaldev.blob.core.windows.net/share/regex_parse_error.png
Adaptive Card JSON
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with multiple Web Chat control instances rendering large base64 attachments, following the listed refresh steps and observing webchat.js and vendors.js. Investigate the attachment-rendering path associated with the reported RegExp.exec stack trace; done means large simultaneous attachments render without a call-stack overflow or an unresponsive browser.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100