Skip to content

Commit

Permalink
add timeout to wait for dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
polats committed May 23, 2023
1 parent 40f59ad commit 0ecd377
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions avatar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,16 @@ export function displayPart(itemPath, rerender) {
// https://stackoverflow.com/questions/43017000/babel-ignores-es6-inside-react-dangerouslysetinnerhtml-script-tag
//
export async function renderAvatar() {
let rend;

const rend = new jsora.Renderer(g_jsoraProject);
try {
rend = new jsora.Renderer(g_jsoraProject);
} catch (e) {
console.log("canvas dimensions not ready, retrying in 1 second");
setTimeout(renderAvatar, 1000);
return;
}
var renderCanvas = await rend.make_merged_image();

var sourceImageData = renderCanvas.toDataURL("image/png");
var destCanvasContext = g_oraCanvas.getContext('2d');
var destinationImage = new Image;
Expand Down
1 change: 0 additions & 1 deletion components/oraglbviewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ let loadedNft:NftMetadata;
return (
<>
<canvas height={canvasSize.height} width={canvasSize.width} ref={reactCanvasBabylon} />
)
{(() => {
if (loading) {
return <NftLoading />
Expand Down

1 comment on commit 0ecd377

@vercel
Copy link

@vercel vercel bot commented on 0ecd377 May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.