# WebView being moved to Native Extension

**URL:** <https://forum.defold.com/t/webview-being-moved-to-native-extension/42565>\
**Category:** Announcements\
**Created:** [February 4, 2019, 3:54pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565 "2019-02-04T15:54:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [February 4, 2019, 3:54pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/1 "2019-02-04T15:54:22Z")

</div>

With Defold release **1.2.146** we are moving the previous core module `webview` into an external native extension library.

If you previously were using `webview` , you will need to add the following URL to your dependencies in `game.project` :

```lua
https://github.com/defold/extension-webview/archive/master.zip

```

### Reasoning

As presented in out [roadmap for H1 2019](https://forum.defold.com/t/defold-roadmap-h1-2019/41406), we are in the process of making the engine runtime more modular.

> During H1-2019 we will use this system to extract non-vital parts of the engine core into native extensions, thus giving users even better control of what to include in the engine core, as well as opening up for community collaboration and improvements. We will start by extracting the webview into a native extension and then move on to also extract push, iap, iac and the Facebook SDK.

The `webview` module is our first step in this direction, it’s a good candidate for us to learn what removing modules from the core would mean for both us and our users.

### Changes

Only a stub implementation is left in engine core, it will throw a Lua error if any `webview` function is used on mobile. The error will look like this:

```lua
webview has been removed from core, please read /builtins/docs/webview.md for more information.

```

### Documentation

The documentation for `webview` is now available here: [Defold webview extension API documentation](https://defold.github.io/extension-webview/)

### Caveats

- The code editor inside Defold will no longer display code completion for the `webview` namespace. We are looking into a general solution for this, where libraries/extensions can expose code completions. However, this feature will not be available in 1.2.146 and we are sorry for the inconvenience. The issue ID for this feature is: **DEFEDIT-1532**

### Feedback

We are open for your feedback and would like to hear any suggestions how we can make this new direction as painless as possible for our users. If you have any suggestions or annoyances how this new direction will affect you, please reply to this topic!

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [February 5, 2019, 7:56pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/2 "2019-02-05T19:56:41Z")

</div>

You will continue use old doc format for webview, or it will use another format? Prev was json, now you use yml, if i understand right.

EmmyLua use lua annotations(something like luadoc) to describe params,functions,types. It is very easy to use it. If in library we can use annotations in lua to make autocomple it will be cool and easy for users. [@return function return type annotation — EmmyLua for IntelliJ IDEA 1.3.2 documentation](https://emmylua.github.io/annotations/return.html)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 5, 2019, 8:29pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/3 "2019-02-05T20:29:45Z")

</div>

> [@d954mas](#):
>
> You will continue use old doc format for webview, or it will use another format?

We have a meeting on Thursday to discuss and hopefully agree on a format for documenting extensions so that the editor can provide autocomplete. I haven’t heard of EmmyLua before but I’ll take a look at it for sure!

---

<div class="post-metadata">

**Author:** ![ch4segames](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@ch4segames](https://forum.defold.com/u/ch4segames)\
**Post date:** [April 11, 2019, 9:59pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/4 "2019-04-11T21:59:27Z")

</div>

I think I’m missing something. The goal wasn’t to disable webview completely, right? Just to switch from a core module to an extension.

I’m using the Defold 1.2.150 with Mac OS 10.12.6 building to a Samsung Galaxy S7. I have a new project using the extension-webview URL above and dirtylarry, which both load into the project fine. I get the following error:

```
ERROR:SCRIPT: /main/main.gui_script:54: webview has been removed from core, please read /builtins/docs/webview.md for more information.
stack traceback:
[C]: in function 'create'

```

webview\_available() returns true. In fact, I can pprint(webview) and get a list of functions. So, as far as I know, I am trying to use webview as an extension. What am I missing?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [April 12, 2019, 12:29am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/5 "2019-04-12T00:29:20Z")

</div>

Can you confirm if you download and build the example project it doesn’t work?

> **[GitHub - defold/extension-webview: Defold extension for creating and controlling...](https://github.com/defold/extension-webview)**
>
> Defold extension for creating and controlling webviews to show html pages or evaluate javascript.

Also did you install an apk built after adding the NE to your phone?

---

<div class="post-metadata">

**Author:** ![ch4segames](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@ch4segames](https://forum.defold.com/u/ch4segames)\
**Post date:** [April 12, 2019, 1:29am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/6 "2019-04-12T01:29:09Z")

</div>

Yes, I used the example project both by including [https://github.com/defold/extension-webview/archive/master.zip](https://github.com/defold/extension-webview/archive/master.zip) as a dependency (then manually creating the script), and in a different project by downloading the zip, unzipping it, and dragging all the files into Defold. On the device, I installed the most recent version of dmengine and used that as the Target. The dirtylarry buttons show up on the device.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [April 12, 2019, 1:57am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/7 "2019-04-12T01:57:57Z")

</div>

Can you download the example and test it just to be sure? I don’t mean including the NE in your own project.

> [@ch4segames](#):
>
> On the device, I installed the most recent version of dmengine

By most recent version of dmengine do you mean one from [d.defold.com](http://d.defold.com) or one you actually built which includes the NE code?

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [April 12, 2019, 6:26am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/8 "2019-04-12T06:26:04Z")

</div>

> and dragging all the files into Defold.

No need to do that. Unzip and double click on game.project.

---

<div class="post-metadata">

**Author:** ![ch4segames](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@ch4segames](https://forum.defold.com/u/ch4segames)\
**Post date:** [April 12, 2019, 11:29am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/9 "2019-04-12T11:29:11Z")

</div>

dmengine came from [engine/armv7-android/dmengine.apk](http://d.defold.com/archive/e79cdece4f5c8498302b3b00591808e3dc5a1827/engine/armv7-android/dmengine.apk) link from the 1.2.150 release at [d.defold.com](http://d.defold.com).

I downloaded [https://github.com/defold/extension-webview/archive/master.zip](https://github.com/defold/extension-webview/archive/master.zip), unzipped it and double-clicked on game.project. When defold came up, I connected to my device under Target, and chose Build. The output in the console was:

```
INFO:ENGINE: Defold Engine 1.2.150 (e79cdec)
INFO:ENGINE: Loading data from: http://192.168.1.27:54694/build
INFO:ENGINE: Initialised sound device 'default'

ERROR:SCRIPT: /main/main.gui_script:54: webview has been removed from core, please read 
   /builtins/docs/webview.md for more information.
     stack traceback:
    [C]: in function 'create'
    /main/main.gui_script:54: in function </main/main.gui_script:48>
ERROR:GAMESYS: Error when initializing gui component: -2.
WARNING:ENGINE: Unknown Android input method [KeyEvent], defaulting to key events

```

On the device, are 3 buttons (“Open [www.google.com](http://www.google.com)”, “Show”, “Hide”). When I hit the “Open” button, I get these additional lines in the console:

```
ERROR:SCRIPT: /main/main.gui_script:66: webview has been removed from core, please read 
/builtins/docs/webview.md for more information.
stack traceback:
    [C]: in function 'open'
    /main/main.gui_script:66: in function 'cb'
    /dirtylarry/dirtylarry.lua:67: in function 'button'
    /main/main.gui_script:63: in function </main/main.gui_script:62>

```

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [April 12, 2019, 11:42am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/11 "2019-04-12T11:42:38Z")

</div>

The issue is that you are running an engine without the webview components built in (the one downloaded from [d.defold.com](http://d.defold.com) is a “vanilla” build, without any extensions).

It’s not possible to build and launch a completely different engine binary directly to the device from the editor.

The solution is to bundle your project once for Android, install that APK to your device instead. Then you will be running a binary that has webview included, so you will be able to run “Build & Launch” to it as a target.

---

<div class="post-metadata">

**Author:** ![ch4segames](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@ch4segames](https://forum.defold.com/u/ch4segames)\
**Post date:** [April 12, 2019, 3:33pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/12 "2019-04-12T15:33:11Z")

</div>

Thanks for sticking with me. I knew I was missing something fundamental. OK. So, now I am set up building an apk and seeing debug messages with adb. When I run on the device, the `webview` table is nil and I get the debug message from `webview_available()`.

I thought that maybe I had to do some manual steps outside of defold, so I tried the example [GitHub - defold/extension-android: Example of a native extension for Android · GitHub](https://github.com/defold/extension-android) using the same process (download zip, double-click the project file, defold Bundle apk, copy apk to device, install on device, run on device (including adb over usb)). The extension-android example runs fine on the device. I’ll try a few more examples and see whether I can narrow down which ones I have issues with.

I am trying to digest the Extensions Manual ([Writing native extensions for Defold](https://www.defold.com/manuals/extensions/)) but I’m not not yet understanding how a table from an extension becomes available in the namespace of a script. There is no `require` so it is compiled in at some point and makes itself available to lua.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [April 13, 2019, 9:05am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/13 "2019-04-13T09:05:50Z")

</div>

> [@ch4segames](#):
>
> There is no `require` so it is compiled in at some point and makes itself available to lua

Exactly. Extensions declare their public Lua API in the extension init code. This usually means creating one or more tables on the Lua global table.

---

<div class="post-metadata">

**Author:** ![viindeveloper](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/v/ba9def/32.png) [@viindeveloper](https://forum.defold.com/u/viindeveloper)\
**Post date:** [July 8, 2019, 2:09pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/14 "2019-07-08T14:09:53Z")

</div>

Hi all,

It seems something was wrong when I bundled to Android with the same sample project from [GitHub - defold/extension-webview: Defold extension for creating and controlling webviews to show html pages or evaluate javascript. · GitHub](https://github.com/defold/extension-webview). My config is: Defold - 1.2.157, MacOS Mojave

07-08 18:43:28.176 7992 8010 E defold : ERROR:SCRIPT: main/main.gui\_script:66: webview has been removed from core, please read /builtins/docs/webview.md for more information.  
07-08 18:43:28.176 7992 8010 E defold : stack traceback:  
07-08 18:43:28.176 7992 8010 E defold : [C]: in function ‘open’  
07-08 18:43:28.176 7992 8010 E defold : main/main.gui\_script:66: in function ‘cb’  
07-08 18:43:28.176 7992 8010 E defold : dirtylarry/dirtylarry.lua:67: in function ‘button’  
07-08 18:43:28.176 7992 8010 E defold : main/main.gui\_script:63: in function \<main/main.gui\_script:62\>

My process: download zip, open project, Project-\> Bundle-\>Android, copy apk to device, install, run on device with no success.

Is there any way to check the webview component has been include in apk file?

Thank you

NamNguyen

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [July 8, 2019, 3:33pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/15 "2019-07-08T15:33:32Z")

</div>

That’s strange, I just tried the same here and it works. Bundled the `extension-webview` project for Android and installed it (via `adb`)… 🤔

You haven’t done any changes to the project, or changed the build server URL preferences?

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/6/3/63bdb99dc1f6938f7e2dbe1b664ad1af1a833ccd.png)

---

<div class="post-metadata">

**Author:** ![viindeveloper](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/v/ba9def/32.png) [@viindeveloper](https://forum.defold.com/u/viindeveloper)\
**Post date:** [July 9, 2019, 4:20am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/16 "2019-07-09T04:20:23Z")

</div>

thanks sven,

I tried both: via adb and manually copy to device, my device is Asus Zenfon4, Android 8.1.0. So if it is bundled as your instructions, the reason maybe is webview could not be invoked?

After error running built with older Defold version, I make a fresh config (download Defold 1.2.157, download webview as zip, run project file, build successfully) with no modification anything, my Extensions config as follow:

 ![45](https://forum-defold-uploads.b-cdn.net/original/3X/b/b/bbc6388413ffc522cb59559e5d780e00adb31861.png)

---

<div class="post-metadata">

**Author:** ![viindeveloper](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/v/ba9def/32.png) [@viindeveloper](https://forum.defold.com/u/viindeveloper)\
**Post date:** [July 10, 2019, 8:08am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/17 "2019-07-10T08:08:13Z")

</div>

Hi sven,

Could you please send me the app at your build?

Thank you very much!

---

<div class="post-metadata">

**Author:** ![sven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sven/32/1086_2.png) [@sven](https://forum.defold.com/u/sven)\
**Post date:** [July 11, 2019, 9:09am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/18 "2019-07-11T09:09:48Z")

</div>

Sent you a PM.

---

<div class="post-metadata">

**Author:** ![andrey.voropaev](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/a/6a8cbe/32.png) [@andrey.voropaev](https://forum.defold.com/u/andrey.voropaev)\
**Post date:** [July 11, 2019, 4:30pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/19 "2019-07-11T16:30:41Z")

</div>

Hi!  
The problem is still relevant.  
Defold **1.2.158**  
Platforms iOS, Android  
When using webview, the error “webview has been removed from core” crashes.  
Build with

> Prodject-\>Bundle-\>ios(android) application

---

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [July 11, 2019, 5:40pm UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/20 "2019-07-11T17:40:21Z")

</div>

> [@andrey.voropaev](#):
>
> Hi!  
> The problem is still relevant.

I found the issue and made a PR, I think we will merge it tomorrow.

---

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [July 12, 2019, 8:35am UTC](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565/21 "2019-07-12T08:35:11Z")

</div>

Merged into `master`, should be fine now.

[Next page](https://forum.defold.com/t/webview-being-moved-to-native-extension/42565.md?page=2)
