capacitor-community / capacitor-community/camera-preview
Running into "Cannot read properties of null (reading 'appendChild')"
- Dominant language
- Java
- Stars
- 227
- Forks
- 185
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I've got an Ionic project using this plugin, and when I call `CameraPreview.start` this error gets spit out in the console:
```
core.mjs:9215 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of null (reading 'appendChild')
TypeError: Cannot read properties of null (reading 'appendChild')
at web.js:43:20
at Generator.next ()
at asyncGeneratorStep (asyncToGenerator.js:3:1)
at _next (asyncToGenerator.js:22:1)
at _ZoneDelegate.invoke (zone.js:372:26)
at Object.onInvoke (core.mjs:25762:33)
at _ZoneDelegate.invoke (zone.js:371:52)
at Zone.run (zone.js:134:43)
at zone.js:1275:36
at _ZoneDelegate.invokeTask (zone.js:406:31)
at resolvePromise (zone.js:1211:31)
at zone.js:1118:17
at zone.js:1134:33
at _ZoneDelegate.invoke (zone.js:372:26)
at Object.onInvoke (core.mjs:25762:33)
at _ZoneDelegate.invoke (zone.js:371:52)
at Zone.run (zone.js:134:43)
at zone.js:1275:36
at _ZoneDelegate.invokeTask (zone.js:406:31)
at core.mjs:25441:55
handleError @ core.mjs:9215
```
**To Reproduce**
Version numbers that are probably relevant:
- Ionic CLI 6.20.4
- Node 18.12.1
- Capacitor Android 4.6.0
- Capacitor Camera 4.1.4
- Capacitor CLI 4.6.0
- Capacitor Core 4.6.0
I'm running this code:
```
const cameraPreviewOptions: CameraPreviewOptions = {
position: 'rear',
height: 1920,
width: 1080
};
CameraPreview.start(cameraPreviewOptions);
```
The error occurs whenever that code is run.
Issue #247 looked similar, but the fixes linked here didn't work for me: https://github.com/Cap-go/camera-preview/pull/3
Any help is appreciated, thanks.
Contributor guide
Assessment
This issue has not been assessed yet.