Skip to content

Commit c17534b

Browse files
Release (#1908)
* fix: image element rendering triggers an exception (#1906) * fix: image element rendering triggers an exception * chore: add image bugfix demo #1906 * chore(release): bump version (#1907) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 2f5d364 commit c17534b

File tree

35 files changed

+181
-23
lines changed

35 files changed

+181
-23
lines changed

.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module.exports = {
4949
'import/no-cycle': 'warn',
5050
'import/no-duplicates': 'warn',
5151
'class-methods-use-this': 'warn',
52+
'no-console': ['warn', { allow: ['warn', 'error'] }],
5253
'no-plusplus': [
5354
'warn',
5455
{

__tests__/demos/bugfix/1906.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Canvas, Image as GImage } from '@antv/g';
2+
3+
/**
4+
* @see https://github.com/antvis/G/pull/1906
5+
*/
6+
export async function issue_1906(context: { canvas: Canvas }) {
7+
const { canvas } = context;
8+
await canvas.ready;
9+
canvas.context.config.enableLargeImageOptimization = true;
10+
11+
const img = new Image();
12+
img.onload = () => {
13+
console.log('onload', img.complete);
14+
15+
// remove && expect no error
16+
requestAnimationFrame(() => {
17+
image.remove();
18+
});
19+
};
20+
21+
let image = new GImage({
22+
style: {
23+
x: 0,
24+
y: 0,
25+
src: img,
26+
},
27+
});
28+
29+
img.src =
30+
'https://mdn.alipayobjects.com/huamei_fr7vu1/afts/img/A*SqloToP7R9QAAAAAAAAAAAAADkn0AQ/original';
31+
32+
canvas.appendChild(image);
33+
}

__tests__/demos/bugfix/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export { test_pick } from './1747';
1010
export { issue_1760 } from './1760';
1111
export { issue_1176 } from './1176';
1212
export { issue_1882 } from './1882';
13+
export { issue_1906 } from './1906';
1314
export { textWordWrap } from './textWordWrap';
1415
export { group_with_stroke } from './group-with-stroke';
1516
export { switchRenderer } from './switch-renderer';

packages/g-canvas/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @antv/g-canvas
22

3+
## 2.0.40
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [cc62be4]
8+
- @antv/g-plugin-canvas-renderer@2.2.19
9+
- @antv/g-plugin-image-loader@2.1.19
10+
- @antv/g-plugin-canvas-picker@2.1.19
11+
312
## 2.0.39
413

514
### Patch Changes

packages/g-canvas/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-canvas",
3-
"version": "2.0.39",
3+
"version": "2.0.40",
44
"description": "A renderer implemented by Canvas 2D API",
55
"keywords": [
66
"antv",

packages/g-canvaskit/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @antv/g-canvaskit
22

3+
## 1.0.39
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [cc62be4]
8+
- @antv/g-plugin-image-loader@2.1.19
9+
- @antv/g-plugin-canvas-picker@2.1.19
10+
- @antv/g-plugin-canvaskit-renderer@2.1.19
11+
312
## 1.0.38
413

514
### Patch Changes

packages/g-canvaskit/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-canvaskit",
3-
"version": "1.0.38",
3+
"version": "1.0.39",
44
"description": "A renderer implemented by CanvasKit",
55
"keywords": [
66
"antv",

packages/g-mobile-canvas/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @antv/g-mobile-canvas
22

3+
## 1.0.37
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [cc62be4]
8+
- @antv/g-plugin-canvas-renderer@2.2.19
9+
- @antv/g-plugin-image-loader@2.1.19
10+
- @antv/g-plugin-canvas-picker@2.1.19
11+
312
## 1.0.36
413

514
### Patch Changes

packages/g-mobile-canvas/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-mobile-canvas",
3-
"version": "1.0.36",
3+
"version": "1.0.37",
44
"description": "A renderer implemented with Canvas2D API in mobile environment",
55
"keywords": [
66
"antv",

packages/g-mobile-webgl/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @antv/g-mobile-webgl
22

3+
## 1.0.44
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [cc62be4]
8+
- @antv/g-plugin-image-loader@2.1.19
9+
- @antv/g-plugin-device-renderer@2.2.19
10+
311
## 1.0.43
412

513
### Patch Changes

packages/g-mobile-webgl/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-mobile-webgl",
3-
"version": "1.0.43",
3+
"version": "1.0.44",
44
"description": "A renderer implemented by WebGL1/2 in mobile environment",
55
"keywords": [
66
"antv",

packages/g-plugin-3d/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/g-plugin-3d
22

3+
## 2.0.42
4+
5+
### Patch Changes
6+
7+
- @antv/g-plugin-device-renderer@2.2.19
8+
39
## 2.0.41
410

511
### Patch Changes

packages/g-plugin-3d/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-3d",
3-
"version": "2.0.41",
3+
"version": "2.0.42",
44
"description": "Provide 3D extension for G",
55
"keywords": [
66
"antv",

packages/g-plugin-canvas-picker/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-plugin-canvas-picker
22

3+
## 2.1.19
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [cc62be4]
8+
- @antv/g-plugin-canvas-renderer@2.2.19
9+
310
## 2.1.18
411

512
### Patch Changes

packages/g-plugin-canvas-picker/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-canvas-picker",
3-
"version": "2.1.18",
3+
"version": "2.1.19",
44
"description": "A G plugin for picking in canvas",
55
"keywords": [
66
"antv",

packages/g-plugin-canvas-renderer/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @antv/g-plugin-canvas-renderer
22

3+
## 2.2.19
4+
5+
### Patch Changes
6+
7+
- cc62be4: fix: image element rendering triggers an exception
8+
- Updated dependencies [cc62be4]
9+
- @antv/g-plugin-image-loader@2.1.19
10+
311
## 2.2.18
412

513
### Patch Changes

packages/g-plugin-canvas-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-canvas-renderer",
3-
"version": "2.2.18",
3+
"version": "2.2.19",
44
"description": "A G plugin of renderer implementation with Canvas2D API",
55
"keywords": [
66
"antv",

packages/g-plugin-canvas-renderer/src/shapes/styles/Image.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,19 @@ export class ImageRenderer extends DefaultRenderer {
4747
if (!imageCache.downSampled) {
4848
this.imagePool
4949
.createDownSampledImage(src, object)
50-
.then((res) => {
50+
.then(() => {
51+
// be removed from dom tree
52+
if (!object.ownerDocument) {
53+
return;
54+
}
55+
5156
// rerender
5257
// object.dirty();
5358
object.renderable.dirty = true;
5459
object.ownerDocument.defaultView.context.renderingService.dirtify();
5560
})
56-
.catch(() => {
57-
//
61+
.catch((reason) => {
62+
console.error(reason);
5863
});
5964

6065
return;
@@ -92,15 +97,20 @@ export class ImageRenderer extends DefaultRenderer {
9297
src,
9398
[],
9499
() => {
100+
// be removed from dom tree
101+
if (!object.ownerDocument) {
102+
return;
103+
}
104+
95105
// rerender
96106
// object.dirty();
97107
object.renderable.dirty = true;
98108
object.ownerDocument.defaultView.context.renderingService.dirtify();
99109
},
100110
object,
101111
)
102-
.catch(() => {
103-
//
112+
.catch((reason) => {
113+
console.error(reason);
104114
});
105115

106116
return;
@@ -244,7 +254,9 @@ export class ImageRenderer extends DefaultRenderer {
244254
imageRect,
245255
drawRect,
246256
});
247-
} catch {}
257+
} catch {
258+
// expected error
259+
}
248260
}
249261

250262
// ---

packages/g-plugin-canvaskit-renderer/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-plugin-canvaskit-renderer
22

3+
## 2.1.19
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [cc62be4]
8+
- @antv/g-plugin-image-loader@2.1.19
9+
310
## 2.1.18
411

512
### Patch Changes

packages/g-plugin-canvaskit-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-canvaskit-renderer",
3-
"version": "2.1.18",
3+
"version": "2.1.19",
44
"description": "A G plugin of renderer implementation with CanvasKit",
55
"keywords": [
66
"antv",

packages/g-plugin-device-renderer/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-plugin-device-renderer
22

3+
## 2.2.19
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [cc62be4]
8+
- @antv/g-plugin-image-loader@2.1.19
9+
310
## 2.2.18
411

512
### Patch Changes

packages/g-plugin-device-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-device-renderer",
3-
"version": "2.2.18",
3+
"version": "2.2.19",
44
"description": "A G plugin of renderer implementation with GPUDevice",
55
"keywords": [
66
"antv",

packages/g-plugin-image-loader/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/g-plugin-image-loader
22

3+
## 2.1.19
4+
5+
### Patch Changes
6+
7+
- cc62be4: fix: image element rendering triggers an exception
8+
39
## 2.1.18
410

511
### Patch Changes

packages/g-plugin-image-loader/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-image-loader",
3-
"version": "2.1.18",
3+
"version": "2.1.19",
44
"description": "A G plugin for loading image",
55
"keywords": [
66
"antv",

packages/g-plugin-image-loader/src/ImagePool.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ export class ImagePool {
8585
.then((cache) => {
8686
callback?.(cache);
8787
})
88-
.catch(() => {
89-
//
88+
.catch((reason) => {
89+
console.error(reason);
9090
});
9191

9292
return null;

packages/g-plugin-rough-canvas-renderer/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/g-plugin-rough-canvas-renderer
22

3+
## 2.0.40
4+
5+
### Patch Changes
6+
7+
- @antv/g-canvas@2.0.40
8+
39
## 2.0.39
410

511
### Patch Changes

packages/g-plugin-rough-canvas-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-rough-canvas-renderer",
3-
"version": "2.0.39",
3+
"version": "2.0.40",
44
"description": "A G plugin of renderer implementation with rough.js",
55
"keywords": [
66
"antv",

packages/g-plugin-zdog-canvas-renderer/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/g-plugin-zdog-canvas-renderer
22

3+
## 2.0.39
4+
5+
### Patch Changes
6+
7+
- @antv/g-canvas@2.0.40
8+
39
## 2.0.38
410

511
### Patch Changes

packages/g-plugin-zdog-canvas-renderer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-plugin-zdog-canvas-renderer",
3-
"version": "2.0.38",
3+
"version": "2.0.39",
44
"description": "A G plugin of renderer implementation with Zdog",
55
"keywords": [
66
"antv",

packages/g-web-components/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-web-components
22

3+
## 2.0.46
4+
5+
### Patch Changes
6+
7+
- @antv/g-canvas@2.0.40
8+
- @antv/g-webgl@2.0.44
9+
310
## 2.0.45
411

512
### Patch Changes

packages/g-web-components/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-web-components",
3-
"version": "2.0.45",
3+
"version": "2.0.46",
44
"description": "A declarative usage for G implemented with WebComponents",
55
"keywords": [
66
"antv",

0 commit comments

Comments
 (0)