-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
poc for adding flush. I think we just need to add `flushCanvasRenderers` as `flush` (also add this for the flushSkiaRenderer) and that should address #336. obviously needs clean up, but just wanna make sure its worth sticking this in. is there a good way to get back to the "issue" request to enquire if this will sort the problem? or do we just update the api and check in? Diffs= ebff4893c poc for adding "flush" (#6237) Co-authored-by: Maxwell Talbot <[email protected]> Co-authored-by: Zachary Plata <[email protected]>
- Loading branch information
1 parent
0332745
commit 3b48f12
Showing
10 changed files
with
196 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
b098ad23a15cc7b11f144e407374c83d5db0fee0 | ||
ebff4893cb0698855530d530a6f952880dceb229 |
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
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
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,78 @@ | ||
export async function checkForLeaks(rive) { | ||
const riveEx = RIVE_EXAMPLES[0]; | ||
const { hasStateMachine } = riveEx; | ||
var stateMachine, animation; | ||
const bytes = await (await fetch(new Request(riveEx.riveFile))).arrayBuffer(); | ||
const file = await rive.load(new Uint8Array(bytes)); | ||
const artboard = file.defaultArtboard(); | ||
artboard.advance(0); | ||
if (hasStateMachine) { | ||
stateMachine = new rive.StateMachineInstance( | ||
artboard.stateMachineByIndex(0), | ||
artboard | ||
); | ||
} else { | ||
animation = new rive.LinearAnimationInstance( | ||
artboard.animationByName(riveEx.animation), | ||
artboard | ||
); | ||
} | ||
const num = 0; | ||
let canvas = document.getElementById(`canvas${num}`); | ||
if (!canvas) { | ||
const body = document.querySelector("body"); | ||
canvas = document.createElement("canvas"); | ||
canvas.id = `canvas${num}`; | ||
body.appendChild(canvas); | ||
} | ||
canvas.width = "400"; | ||
canvas.height = "400"; | ||
// Don't use the offscreen renderer for FF as it should have a context limit of 300 | ||
const renderer = rive.makeRenderer(canvas, true); | ||
var elapsedSeconds = 0.0167; | ||
// Render 20 frames. | ||
for (var i = 0; i < 1000; i++) { | ||
renderer.clear(); | ||
if (artboard) { | ||
if (stateMachine) { | ||
stateMachine.advance(elapsedSeconds); | ||
} | ||
if (animation) { | ||
animation.advance(elapsedSeconds); | ||
animation.apply(1); | ||
} | ||
artboard.advance(elapsedSeconds); | ||
renderer.save(); | ||
renderer.align( | ||
rive.Fit.contain, | ||
rive.Alignment.center, | ||
{ | ||
minX: 0, | ||
minY: 0, | ||
maxX: canvas.width, | ||
maxY: canvas.height, | ||
}, | ||
artboard.bounds | ||
); | ||
artboard.draw(renderer); | ||
renderer.restore(); | ||
} | ||
renderer.flush(); | ||
} | ||
|
||
renderer.delete(); | ||
if (stateMachine) { | ||
stateMachine.delete(); | ||
} | ||
if (animation) { | ||
animation.delete(); | ||
} | ||
if (artboard) { | ||
artboard.delete(); | ||
} | ||
file.delete(); | ||
rive.cleanup(); | ||
// Report any leaks. | ||
rive.doLeakCheck(); | ||
console.log("END"); | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<canvas id="canvas0"></canvas> | ||
<canvas id="rive-canvas"></canvas> | ||
<script src="./index.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.