You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/05/21 09:27:52 UTC

[GitHub] [incubator-echarts] luruxi commented on issue #9383: echarts渲染不出来报错

luruxi commented on issue #9383: echarts渲染不出来报错
URL: https://github.com/apache/incubator-echarts/issues/9383#issuecomment-494314107
 
 
   > I have solved this problem in my project.
   > 
   > When I debuged my project, it would sometimes log the errors like this:
   > ![image](https://user-images.githubusercontent.com/17041261/54177227-7ba5ee80-44cc-11e9-9aaa-f8e26799ec00.png)
   > 
   > From the errors tips, it significantly show that this error appeared when execute this code:
   > 
   > ```
   > this.ctx.dpr = this.dpr
   > ```
   > 
   > in `Layer.js` 、`Painter.js`、`zrender.js` etc.
   > 
   > So I detect the Layer.js file, in `node_modules\zrender\lib\Layer.js` , I saw this code in a function named 'initContext':
   > 
   > ```
   > initContext: function () {
   >     this.ctx = this.dom.getContext('2d');
   >     this.ctx.dpr = this.dpr;
   >   },
   > ```
   > 
   > I modified this function to the code below:
   > 
   > ```
   > initContext: function () {
   >     this.ctx = this.dom.getContext('2d');
   >     try {
   >       this.ctx.dpr = this.dpr;
   >     } catch (e) {
   >       setTimeout(() => {
   >         location.reload()
   >       }, 500)
   >     }
   >   },
   > ```
   > 
   > And the bug resolved.
   > 
   > I think this is a iOS bug happened occasionally, when the Layer.js or other Javascript library execute the command like `this.ctx = this.dom.getContext('2d');`,the lib find `this.dom` is not found, `this.dom` here represent the HTMLCanvasElement. It exactly is a canvas element in most time, when the iOS javascript engines display correctly, but sometimes it would not, it was not found instead. So `this.ctx` is `null`, so it will throw error when execute `this.ctx.dpr = this.dpr;`.
   
   Thank you. I'll try

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org