google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://mediapipe.dev
Apache License 2.0
26.8k stars 5.09k forks source link

Uncaught (in promise) TypeError: Cannot read property 'buffer' of undefined #2469

Closed thomhut closed 3 years ago

thomhut commented 3 years ago

Using MediaPipe Pose example for JavaScript. Modified it a bit (see attached). Running on Windows 10 in Chrome Browser. Works as expected about 50% of the time but then throws errors in the console the other 50%. This is one example of an error that it throws. I've attached the file I'm using as well as the error log.

index.txt 192.168.1.81-1630016886258.log

google-ml-butler[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

sgowroji commented 3 years ago

Hi @thomhut, Could you please have a look at this https://github.com/google/mediapipe/issues/2189#issuecomment-880112598. Which address your query. Thanks!

google-ml-butler[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] commented 3 years ago

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] commented 3 years ago

Are you satisfied with the resolution of your issue? Yes No

ats05 commented 2 years ago

This isssue was closed... but I've had a similar problem in my environment, so I'll note it here. This error does not always occur.

When I had this error, all resources was completed download with 200, including "https://cdn.jsdelivr.net/npm/@mediapipe/pose@0.4.1630009814/pose_solution_packed_assets.data".

I will post again if I know something.

pose_solution_simd_wasm_bin.js:9 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'buffer') at Object.write (VM696 pose_solution_simd_wasm_bin.js:9) at Object.write (VM696 pose_solution_simd_wasm_bin.js:9) at Object.createDataFile (VM696 pose_solution_simd_wasm_bin.js:9) at finish (VM696 pose_solution_simd_wasm_bin.js:9) at processData (VM696 pose_solution_simd_wasm_bin.js:9) at Object.createPreloadedFile [as FS_createPreloadedFile] (VM696 pose_solution_simd_wasm_bin.js:9) at DataRequest.finish (VM695 pose_solution_packed_assets_loader.js:140) at DataRequest.onload (VM695 pose_solution_packed_assets_loader.js:135) at processPackageData (VM695 pose_solution_packed_assets_loader.js:17

ats05 commented 2 years ago

What @tyrmullen said here was correct. However, it was difficult to understand.

Some resources seem to be downloaded when call a function Pose.initialize(). And this function will return a Promise Object, so you have to wait for it to be resolved.

Please refer the demo of tfjs-models https://github.com/tensorflow/tfjs-models/blob/master/pose-detection/src/blazepose_mediapipe/detector.ts#L173

The source code at the beginning of this issue should be modified like this

    const pose = new Pose({locateFile: (file) => {
      return `https://cdn.jsdelivr.net/npm/@mediapipe/pose/${file}`;
    }});
    pose.setOptions({
      modelComplexity: 1,
      smoothLandmarks: true,
      enableSegmentation: false,
      smoothSegmentation: false,
      minDetectionConfidence: 0.5,
      minTrackingConfidence: 0.5
    });

    pose.onResults(onResults);
+    pose.initialize().then( () => {
+       (Start detection or something)
+    });