Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] resizing map when map not visible causes Failed to execute 'drawImage' on 'CanvasRenderingContext2D' exception #421

Closed
techfg opened this issue Apr 30, 2024 · 0 comments
Labels

Comments

@techfg
Copy link
Collaborator

techfg commented Apr 30, 2024

Describe the bug

When autoresize is enabled, during a resize event if the map is not visible and there are one (or more) areas that have state (e.g., selected, highlighted, etc.), the following exception is encountered:

image

jquery.imagemapster.js:1536  Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.
    at r.Graphics.render (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:14938)
    at r.Graphics.addShapeGroup (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:13237)
    at i.AreaData.drawSelection (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:32782)
    at i.AreaData.<anonymous> (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:25145)
    at Function.each (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js:2:3129)
    at w.MapData.redrawSelections (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:25090)
    at h (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:35267)
    at f.MapData.resize (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:36233)
    at f.MapData.autoResize (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:36290)
    at i (https://cdnjs.cloudflare.com/ajax/libs/imagemapster/1.6.0/jquery.imagemapster.min.js:7:36465)
render @ jquery.imagemapster.js:1536
addShapeGroup @ jquery.imagemapster.js:1382
drawSelection @ jquery.imagemapster.js:3460
(anonymous) @ jquery.imagemapster.js:2705
each @ jquery.min.js:2
redrawSelections @ jquery.imagemapster.js:2703
h @ jquery.imagemapster.js:3794
f.MapData.resize @ jquery.imagemapster.js:3872
f.MapData.autoResize @ jquery.imagemapster.js:3878
i @ jquery.imagemapster.js:3897
setTimeout (async)
(anonymous) @ jquery.imagemapster.js:3904
dispatch @ jquery.min.js:2
v.handle @ jquery.min.js:2

Reproduction

https://jsfiddle.net/techfg/h793ptjz/133/

Steps to reproduce

  1. Go to https://jsfiddle.net/techfg/h793ptjz/133/
  2. Resize the preview window - all is OK
  3. Click the Toggle Map Visibility button - the map will be hidden
  4. Resize the preview window
  5. Click the Toggle Map Visibility button

The exception is encountered on step 4 and the button does not show the map in step 5.

Environment Info

Windows 11 Edge Version 124.0.2478.67 (Official build) (64-bit) but should be reproducible in any browser.

Expected Behavior

No errors in console during step 4 and step 5 shows the map.

Additional Information

No response

@techfg techfg added the bug label Apr 30, 2024
@techfg techfg changed the title [🐞] resizing map when not visible causes "" exception [🐞] resizing map when map not visible causes `Failed to execute 'drawImage' on 'CanvasRenderingContext2D' exception Apr 30, 2024
@techfg techfg changed the title [🐞] resizing map when map not visible causes `Failed to execute 'drawImage' on 'CanvasRenderingContext2D' exception [🐞] resizing map when map not visible causes Failed to execute 'drawImage' on 'CanvasRenderingContext2D' exception Apr 30, 2024
@techfg techfg changed the title [🐞] resizing map when map not visible causes Failed to execute 'drawImage' on 'CanvasRenderingContext2D' exception [🐞] resizing map when map not visible causes Failed to execute 'drawImage' on 'CanvasRenderingContext2D' exception Apr 30, 2024
@techfg techfg closed this as completed in 5116cec May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant