# drawImage not working immediately after runRenderingContext

**URL:** <https://devforum.zoom.us/t/drawimage-not-working-immediately-after-runrenderingcontext/77202>\
**Category:** Zoom Apps\
**Created:** [October 10, 2022, 9:42pm UTC](https://devforum.zoom.us/t/drawimage-not-working-immediately-after-runrenderingcontext/77202 "2022-10-10T21:42:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![willpjohnson](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/willpjohnson/32/42122_2.png) [@willpjohnson](https://devforum.zoom.us/u/willpjohnson)\
**Post date:** [October 10, 2022, 9:42pm UTC](https://devforum.zoom.us/t/drawimage-not-working-immediately-after-runrenderingcontext/77202/1 "2022-10-10T21:42:23Z")

</div>

**Zoom Apps Configuration**  
I’m working on a Vue/Vuex app that runs `config` and `runRenderingContext` on mount and runs `drawImage` on input.

**Description**  
If I trigger a `drawImage` too shortly after `runRenderingContext`, I get an error. If I do this after waiting a few seconds from app load or after an app reload, I get no issues.

**Error?**  
`The Zoom client encountered an error while processing the request!{"imageId":"s8kd85UiQMW1gvXDVhmDAw_864_16_408_296_3"}`

I’m calling the following code, as dispatched in an action from `mounted()`:

```auto
zoomSdk.config({
  version: '0.16',
  popoutSize: { width: state.layer.width, height: 720 },
  capabilities: [
    'shareApp',
    'getRunningContext',
    'runRenderingContext',
    'closeRenderingContext',
    'drawParticipant',
    'clearParticipant',
    'drawImage',
    'clearImage',
    'drawWebView',
    'clearWebview',
    'postMessage',
    'sendAppInvitationToAllParticipants',
    'setVideoMirrorEffect',
    'onMessage',
    'onMyMediaChange',
    'onRenderedAppOpened',
  ],
}).then(() => {
  zoomSdk.runRenderingContext({
    view: 'camera',
  })
});

```

then, on an action dispatched from the click of a button on the sidebar, I’m calling the following code

```auto
zoomSdk.drawImage({
  imageData: img,
  x: 1280 - layerPadding.h - state.layer.width,
  y: layerPadding.v,
  zIndex: 3,
})

```

where `img` is a successful `getImageData` call from a canvas element.

The issue, as I understand it from reading various documentation and [this issue](https://devforum.zoom.us/t/drawimage-in-camera-mode-returning-an-error/72505), is that `runRenderingContext` isn’t ready yet. But when I disable the button until `.then()` statement after my call `runRenderingContext` call, the issue persists. The button is disabled, then turns on, and still throws the error.

---

<div class="post-metadata">

**Author:** ![Robert.Wallis](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/robert.wallis/32/38438_2.png) [@Robert.Wallis](https://devforum.zoom.us/u/Robert.Wallis)\
**Post date:** [October 15, 2022, 12:17am UTC](https://devforum.zoom.us/t/drawimage-not-working-immediately-after-runrenderingcontext/77202/2 "2022-10-15T00:17:43Z")

</div>

Yes this is a common issue we are seeing.  
I think the most reliable solution is to check in your `then(config)` (note you are missing the argument config in the then function) that `config.runningContext === "inCamera"`, if that is true, then call drawParticipant, drawWebView, drawImage.

This means that your code is running in the camera mode webview, and not in the sidebar webview at the wrong time.

It is possible to still call these APIs from the sidebar by waiting for `onRunningContextChange` after `runRenderingContext` is successful.

Basically, CEF needs time to initialize.
