收藏
回答

rich-text 组件解析较长 svg path 时发生栈溢出

框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
小程序 Bug rich-text 微信iOS客户端 6.6.6 1.4.0 及以上

rich-text 中,路径较长(一般的图标完全可以达到)的 svg 解析过程中会发生栈溢出。

上面的代码使用调试输出最完整的基础库 1.9.0 进行测试,报错如下:


VM9442:2 webviewScriptError

Maximum call stack size exceeded;[Exparser] [Error] [Component] Lifetime Method Error @ wx-rich-text#attached

RangeError: Maximum call stack size exceeded

   at u (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19183)

   at e (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19775)

   at u (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19319)

   at e (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19775)

   at u (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19319)

   at e (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19775)

   at u (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19319)

   at e (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19775)

   at u (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19319)

   at e (http://127.0.0.1:58060/__pageframe__/__dev__/WAWebview.js:13:19775)


随便找个形状稍微复杂一些的svg图标替换上述代码,也能复现。

我们的产品用 rich-text 解析微信推送文章,上述问题会影响线上版本的有关功能,希望得到修复。

<rich-text nodes='<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewbox="0 0 182 331" style="vertical-align: middle;max-width: 100%;" width="100%"><path d="M8.8,309.4c-0.1-0.2-0.2-0.3-0.2-0.5c-0.1-0.1-0.1-0.3-0.1-0.4c-0.1-0.2-0.1-0.3-0.1-0.5c0,0,0-0.1,0-0.1c0-0.1,0-0.2,0-0.3 c0-0.2-0.1-0.3-0.1-0.5c0-0.1,0-0.3,0-0.4c0-0.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.3-0.2l0.1,0c0,0,0,0,0,0c0.4-0.2,0.8-0.5,1.2-0.6c0,0,0,0,0,0 c0,0,0,0,0,0c0.8-0.4,1.6-0.8,2.6-1.3c0,0,0,0,0.1,0l0,0c0,0,0.1,0,0.1-0.1c0.4-0.2,0.8-0.4,1.3-0.6c0.2-0.1,0.5-0.2,0.7-0.3 c0.2-0.1,0.4-0.2,0.6-0.2c0.4-0.2,0.9-0.4,1.4-0.5c2.3-18.8,4.6-37.7,6.9-56.5c-0.2-0.1-0.4-0.2-0.6-0.3c-0.2-0.1-0.3-0.2-0.5-0.3 c-0.4-0.2-0.8-0.4-0.9-0.5c-0.2-0.1-0.3-0.2-0.5-0.3c-0.8-0.4-1.5-0.9-2.2-1.3l-0.5-0.3c-0.1-0.1-0.2-0.1-0.3-0.2z" fill="rgb(255,0,0)"></path></svg>' />
最后一次编辑于  2018-05-08
回答关注问题邀请回答
收藏

3 个回答

  • 小程序技术专员-june
    小程序技术专员-june
    2018-05-08

    后续版本会优化这里的解析器。


    另外rich-text暂时是不支持svg的,可以参考目前支持的标签(https://developers.weixin.qq.com/miniprogram/dev/component/rich-text.html)。

    2018-05-08
    有用
    回复 1
    • 太阳
      太阳
      2018-09-08

      官方你们能不能把  rich-text  解析和公众号文章那样

      稍微多写一点东西 Maximum call stack size exceeded

      2018-09-08
      回复
  • 罗梅光
    罗梅光
    2019-06-05

    在开发者工具及测试机上不会报这种错误,但在小程序后台就有这种错误,请问你解决了吗?

    2019-06-05
    有用
    回复
  • 浩东
    浩东
    2018-08-07

    题主怎么解决的?

    2018-08-07
    有用
    回复
登录 后发表内容