# WKWebView\* pointer causes EXC\_BAD\_ACCESS in AU Component

**URL:** <https://iplug2.discourse.group/t/wkwebview-pointer-causes-exc-bad-access-in-au-component/370>\
**Category:** macOS\
**Created:** [27 March 2021 20:12 UTC](https://iplug2.discourse.group/t/wkwebview-pointer-causes-exc-bad-access-in-au-component/370 "2021-03-27T20:12:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TA70](https://avatars.discourse-cdn.com/v4/letter/t/d2c977/32.png) [@TA70](https://iplug2.discourse.group/u/TA70)\
**Post date:** [27 March 2021 20:12 UTC](https://iplug2.discourse.group/t/wkwebview-pointer-causes-exc-bad-access-in-au-component/370/1 "2021-03-27T20:12:52Z")

</div>

Hello all,

Now before we start, I realise that the webview component is experimental, however this is a potential bug that I’ve found. Specifically the IWebView::EvaluateJavaScript void in IPlugWebView.mm

Line 180 ( WKWebView\* webView = ( **\_\_bridge** WKWebView\*) mWKWebView;) causes an EXC\_BAD\_ACCESS code=1.

This happens when EvaluateJavaScript is called while the plugin UI is closed, or closing as the webview object it’s trying to reference is no longer in memory I would assume.  
**Only happens with AU**. VST3 does not cause this exception it would appear (better internal memory access exception handling? _shrug_).

I’ve tried creating a flag in CloseWebView(), but it doesn’t work to prevent line 180 from being called after the window closes, even if I wrap the whole contents of the EvaluateJavaScript void in an if statement to see if the flag is active.

Would appreciate any input anyone else has! Thank you.

---

<div class="post-metadata">

**Author:** ![olilarkin](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/olilarkin/32/2_2.png) [@olilarkin](https://iplug2.discourse.group/u/olilarkin)\
**Post date:** [27 March 2021 20:43 UTC](https://iplug2.discourse.group/t/wkwebview-pointer-causes-exc-bad-access-in-au-component/370/2 "2021-03-27T20:43:33Z")

</div>

Thanks for the report. There is a bug here where AUv2 plug-ins using WebViewEditorDelegate don’t call CloweWebView()… working on a fix

---

<div class="post-metadata">

**Author:** ![TA70](https://avatars.discourse-cdn.com/v4/letter/t/d2c977/32.png) [@TA70](https://iplug2.discourse.group/u/TA70)\
**Post date:** [27 March 2021 20:48 UTC](https://iplug2.discourse.group/t/wkwebview-pointer-causes-exc-bad-access-in-au-component/370/3 "2021-03-27T20:48:07Z")

</div>

Thank you for the very quick response!

---

<div class="post-metadata">

**Author:** ![olilarkin](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/olilarkin/32/2_2.png) [@olilarkin](https://iplug2.discourse.group/u/olilarkin)\
**Post date:** [28 March 2021 12:10 UTC](https://iplug2.discourse.group/t/wkwebview-pointer-causes-exc-bad-access-in-au-component/370/4 "2021-03-28T12:10:52Z")

</div>

Should be fixed now: [WebViewEditorDelegate: Fix crash when closing the UI in AUv2 plug-ins. · iPlug2/iPlug2@f3be31f · GitHub](https://github.com/iPlug2/iPlug2/commit/f3be31faf0a4a8806a498260688b381bdcb36c7e)

---

<div class="post-metadata">

**Author:** ![TA70](https://avatars.discourse-cdn.com/v4/letter/t/d2c977/32.png) [@TA70](https://iplug2.discourse.group/u/TA70)\
**Post date:** [29 March 2021 18:33 UTC](https://iplug2.discourse.group/t/wkwebview-pointer-causes-exc-bad-access-in-au-component/370/5 "2021-03-29T18:33:54Z")

</div>

Thank you so much! This has certainly fixed the issue.

**Note** : For anyone else reading this and performing a git pull, you’ll need to edit your Build Phases for each target in XCode to remove the “-fobjc-arc” compiler flag from every file in the Compile Sources section, _ **except** _ on IPlugWebView.mm
