-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(g-canvas): fix webkit ios canvas garbage collection bug (#725)
* feat(g-canvas): fix webkit ios canvas garbage collection bug * feat(g-canvas): 增加 #726 bug单测 Co-authored-by: caoxun03 <caoxun03@kuaishou.com>
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const expect = require('chai').expect; | ||
import { Canvas } from '../../src'; | ||
const container = document.createElement('canvas'); | ||
document.body.appendChild(container); | ||
|
||
describe('#726', () => { | ||
it('Total canvas memory use exceeds xxxMB bug', () => { | ||
const canvas = new Canvas({ | ||
container, | ||
width: 600, | ||
height: 500, | ||
}); | ||
|
||
const canvasEl = canvas.get('el'); | ||
const pixelRatio = canvas.getPixelRatio(); | ||
|
||
expect(canvasEl.width).eql(600 * pixelRatio); | ||
expect(canvasEl.height).eql(500 * pixelRatio); | ||
|
||
canvas.destroy(); | ||
|
||
// 销毁canvas后需要设置宽高为0 | ||
// 解决ios场景下 canvas无法进行垃圾回收的问题 | ||
expect(canvasEl.width).eql(0); | ||
expect(canvasEl.height).eql(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters