WebAssembly provides a way to run C and C++ code (among others) on the web at near native speed.
WebAssembly is designed to complement and run alongside JavaScript. By using the WebAssembly JavaScript APIs, you can load WebAssembly modules into a JavaScript Smart device application and share functionality between the two.
WebAssembly is being developed as a web standard via the W3C WebAssembly Working Group and Community Group with active participation from all major browser vendors.
Samsung smart devices support WebAssembly from Tizen 5.5 (2020 models) onwards.
Typical WebAssembly Web Application Structure
The following sections cover the structure of a typical WebAssembly Web application.
Application Contents
A WebAssembly Web application is composed of at least the following files:
An "index.html" file - Defines the web page that the WebAssembly modules run on. You can include other HTML5 and JavaScript elements, such as additional HTML files, CSS styles, and JavaScript code.
A "config.xml" file - Contains the configuration for the Samsung Web application. This file is automatically generated by the Tizen Studio, but can be omitted when testing the application in a web browser.
At least 1 ".wasm" file: A binary compiled using a WebAssembly toolchain.
HTML Web Page
The "index.html" file is a standard HTML file. To implement WebAssembly modules in the application, you need to use one of the methods presented on the Loading and running WebAssembly code page. Tizen Studio generates required HTML and JavaScript code snippets that wrap one of those methods automatically when sample WebAssembly modules are added.
The ModuleLoader JavaScript class of the generated helper code supports passing canvas and textarea objects to it, so that the loaded WebAssembly module can work with both graphics and text output elements of the web page.
Configuration File
The "config.xml" file is a Tizen-specific file that is created for every Tizen application. The file is automatically generated by the Tizen Studio. The following is an example of a "config.xml" file:
You need native code to exchange information with the web page of your application, which can, for example, provide the user interface. There are several ways described on how to achieve that in Interacting with code. The document shows how native objects may be used from JavaScript code and vice versa.
It is also possible that the native code does not communicate with the web page at all and it provides all the application functionality itself.
Application Code in C/C++
There are no specific requirements for the native application code. The only exception is the possible requirements for accessing native objects from JavaScript code, as described in Interacting with code.
To get started with a simple example, try a typical hello world example:
#include <iostream>
int main() {
std::cout << "Hello from native app" << std::endl;
return 0;
}
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.