From 8ed3cd5e7eda19671be0f2f48e4f69ace84c5a38 Mon Sep 17 00:00:00 2001
From: Frank Sauerburger <frank@sauerburger.com>
Date: Mon, 29 Mar 2021 20:51:22 +0200
Subject: [PATCH] Add debug output for canvas conversion

---
 uhepp-js/src/components/UheppHist.jsx | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/uhepp-js/src/components/UheppHist.jsx b/uhepp-js/src/components/UheppHist.jsx
index 4033ea2..b6b22d0 100644
--- a/uhepp-js/src/components/UheppHist.jsx
+++ b/uhepp-js/src/components/UheppHist.jsx
@@ -640,29 +640,40 @@ const UheppHistPost = ({width, height, uhepp}) => {
 
   const generatePng = () => {
     setPngInProgress(true)
+    console.log("Conversion starting...")
     const canvas = canvasRef.current
     const ctx = canvas.getContext('2d')
+    console.log("Obtained context")
     const svg = svgRef.current.cloneNode(true)
+    console.log("Deep clone of SVG done")
     svg.setAttribute("height", `${canvasHeight}px`)
     svg.setAttribute("width", `${canvasWidth}px`)
     const data = (new XMLSerializer()).serializeToString(svg)
+    console.log("Serialization of SVG done")
 
     const svgBlob = new Blob([data], {type: 'image/svg+xml;charset=utf-8'})
     const url = URL.createObjectURL(svgBlob)
+    console.log("Object URL for SVG blog done")
 
     const img = new Image()
 		img.onload = () => {
+      console.log("Image loaded")
       ctx.clearRect(0, 0, canvas.width, canvas.height)
 			ctx.drawImage(img, 0, 0)
+      console.log("Image drawn on canvas")
 			URL.revokeObjectURL(url)
 
 			canvas.toBlob(blob => {
+        console.log("Canvas to blob done")
 				const pngUrl = URL.createObjectURL(blob)
+        console.log("blob to object URL done")
 				setPngDownload(pngUrl)
 				setPngInProgress(false)
+        console.log("Conversion completed")
 			}, "image/png")
 		}
 		img.src = url
+    console.log("Image URL has been set to Blob")
   }
 
   const defaultColorsCycle = new ColorCycle([
-- 
GitLab