vladmandic/face-api

Detached EventHandlers when running on a Canvas

rebser opened this issue · 3 comments

Issue Description

When running on a Canvas, EventHandlers are leaking.

Steps to Reproduce

Just run for example tinyFaceDetector on a Canvas.

Expected Behavior

face-api should not produce Detached EventHandlers

**Environment

Browser

Turns out the bug is in awaitMediaLoaded.

if (media instanceof env.getEnv().Canvas || isMediaLoaded(media)) resolve(null);
doesn't do the trick because it resolves the Promise to null but doesn't return, meaning the EventHandlers for load and error are still being added.

Solution:
if (media instanceof env.getEnv().Canvas || isMediaLoaded(media)) { resolve(null); return; }

great job tracing it down - do you wan to submit a pr or do you want me to patch it?