Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Draft: Optimization size of wasm binary #25

Draft
wants to merge 207 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
af908d7
Add dependencies for logger
Kirguir Jan 15, 2019
023ac33
Impl simple logger and dual logger
Kirguir Jan 15, 2019
5d4a315
Upd CHANGELOG
Kirguir Jan 16, 2019
74b4e12
Remove CHANGELOG
Kirguir Jan 16, 2019
52a65d3
Impl member and members repository
Kirguir Jan 17, 2019
122d780
Impl handle WS connection
Kirguir Jan 18, 2019
579d4a4
Merge branch 'master' into add_member
Kirguir Jan 18, 2019
d0d691f
Impl default caller and responder
Kirguir Jan 18, 2019
89dee99
Merge branch 'add_member' into handle_ws
Kirguir Jan 18, 2019
278116d
Corrections
tyranron Jan 21, 2019
61366f2
Add state to context ws session
Kirguir Jan 21, 2019
3ef7c30
Add hashmap macro
Kirguir Jan 21, 2019
747ab14
Impl control API errors
Kirguir Jan 22, 2019
c556eb4
Merge branch 'add_member' into handle_ws
Kirguir Jan 22, 2019
8b8edb8
Impl WsSessionRepository
Kirguir Jan 25, 2019
04afc2d
Some corrections
tyranron Jan 28, 2019
c00ad31
Impl remove session from repository
Kirguir Jan 28, 2019
251b3e0
Remove impl actor for MemberRepository
Kirguir Jan 28, 2019
f22945e
Remove unused crates
Kirguir Jan 29, 2019
368b805
Merge branch 'add_member' into handle_ws
Kirguir Jan 29, 2019
0e854d0
Fill up missing docs
tyranron Jan 29, 2019
4bb6096
Remove impl actor for WsSessionRepository
Kirguir Jan 30, 2019
fcb1072
Refactoring and simplify WsSessionRepository
Kirguir Jan 30, 2019
ded6728
Merge branch 'add_member' into handle_ws
Kirguir Jan 30, 2019
4174597
Add docs
Kirguir Jan 30, 2019
1ab77fe
Returns cloned member from repo
Kirguir Jan 31, 2019
ef72144
Merge branch 'add_member' into handle_ws
Kirguir Jan 31, 2019
5d46ecb
Merge branch 'master' into handle_ws
Kirguir Jan 31, 2019
75b48cc
Some fix
Kirguir Jan 31, 2019
f669e41
Add dependencies
Kirguir Jan 31, 2019
1852bad
Remove checking old connection of member
Kirguir Feb 4, 2019
1a3caca
Impl test for handler ws connection
Kirguir Feb 5, 2019
7cfc1eb
Impl handle event
Kirguir Feb 6, 2019
3301284
Impl settings
Kirguir Feb 6, 2019
50adead
Impl handle Command::Close
Kirguir Feb 6, 2019
7b84926
Impl close message
Kirguir Feb 7, 2019
4b0a60b
Add docs
Kirguir Feb 7, 2019
7edfc62
Add heartbeat messages
Kirguir Feb 8, 2019
0ca4987
Impl handle heartbeat messages
Kirguir Feb 8, 2019
76ae3b0
Refactoring repositories
Kirguir Feb 12, 2019
00c7610
Impl simple peer state machine
Kirguir Feb 13, 2019
3e37b5b
Remove redudant serde_derive dependency
tyranron Feb 13, 2019
3183780
Refactor
tyranron Feb 13, 2019
7a5117d
Impl room and repository of rooms
Kirguir Feb 21, 2019
4e696cb
Merge branch 'handle_ws' into add_peer
Kirguir Feb 21, 2019
53ea312
fix disconnects_on_idle test, use FutureResponse instead of HttpResponse
alexlapa Feb 22, 2019
0c650d0
abstract on transport
alexlapa Feb 25, 2019
96d6845
Impl peers
Kirguir Feb 25, 2019
a71d5f3
Simplify RpcConnection trait
Kirguir Feb 25, 2019
261ed38
Impl correct close WsSession
Kirguir Feb 26, 2019
0470201
Fix send close message to Room
Kirguir Feb 27, 2019
e9523b1
Merge branch 'handle_ws' into add_peer
Kirguir Feb 27, 2019
55b9c3e
Impl crate offers for caller and responder
Kirguir Mar 1, 2019
4703bd3
Impl receive sdp_answer and send it to caller
Kirguir Mar 4, 2019
6687b87
Impl create tracks and store link into peers
Kirguir Mar 7, 2019
d82e299
Move room to media module
Kirguir Mar 8, 2019
0decf28
impl ice candidates relay, impl test client, refactor
alexlapa Mar 11, 2019
f99aab5
Merge branch 'master' into add_peer
Kirguir Mar 11, 2019
c652287
Move command and event to client module
Kirguir Mar 12, 2019
ffeb144
Impl send event by Room
Kirguir Mar 19, 2019
756f293
Impl handle Command::MakeSdpOffer
Kirguir Mar 20, 2019
90201da
Impl return future by handler Command
Kirguir Mar 21, 2019
bda5ba2
Fix errors
Kirguir Mar 22, 2019
7b37a1d
Merge branch 'master' into add_config
Kirguir Mar 22, 2019
0b454ca
Add docs
Kirguir Mar 22, 2019
754ab25
refactor, pass conf file path in args/env, serde duration via humanti…
alexlapa Mar 25, 2019
29461ba
Add docs
Kirguir Mar 26, 2019
41b33ee
refactor, extend tests
alexlapa Mar 26, 2019
e56f783
add dummy medea-client crate, dummy e2e client
alexlapa Mar 26, 2019
5739177
add dummy test, update Cargo.toml
alexlapa Mar 27, 2019
ac1212d
Merge remote-tracking branch 'origin/add_config' into bootstrap-web-c…
alexlapa Mar 27, 2019
70c1333
run medea-client unit tests in docker
alexlapa Mar 27, 2019
30550cd
Impl remove peers of member on close RPC connection.
Kirguir Mar 28, 2019
2ca0a6a
Merge branch 'peer_actor' into add_peer
Kirguir Mar 28, 2019
8749709
fix make test.unit
alexlapa Mar 28, 2019
55169da
Some fix
Kirguir Mar 28, 2019
e5d37ea
add make deps
alexlapa Mar 28, 2019
dbe153b
add make up.dev
alexlapa Mar 28, 2019
39e0747
Refactoring watchdog for RPC connection
Kirguir Mar 29, 2019
3aff730
Update test for room
Kirguir Mar 29, 2019
da108a8
change layout
alexlapa Apr 1, 2019
76ea032
remove dockerized from makefile
alexlapa Apr 1, 2019
7533961
readme's
alexlapa Apr 1, 2019
db419cd
remove cfg_if
alexlapa Apr 1, 2019
335d140
add dummy ws
alexlapa Apr 1, 2019
dbfab9a
add dummy ws
alexlapa Apr 1, 2019
6e7633f
Refactoring of handler established RPC connection
Kirguir Apr 3, 2019
ea0d3d8
rename medea-client to jason
alexlapa Apr 3, 2019
dad84cb
connect to socket in e2e app
alexlapa Apr 3, 2019
2c094d8
add jason to workspace
alexlapa Apr 3, 2019
1d7cc52
fix makefile
alexlapa Apr 3, 2019
06774bb
Handler error send event
Kirguir Apr 4, 2019
f601964
draft
alexlapa Apr 4, 2019
0d472b8
Impl transition into failure state for peer
Kirguir Apr 5, 2019
83f139d
implementing transport
alexlapa Apr 5, 2019
d3cd4a8
Revert rename ws session
Kirguir Apr 8, 2019
022c980
Merge branch 'master' into add_peer
Kirguir Apr 8, 2019
7eb2837
Ignore connection errors when closing Room
Kirguir Apr 8, 2019
135abd3
handle on close: stop pinger, remove socket
alexlapa Apr 8, 2019
7b48542
move transport to package
alexlapa Apr 8, 2019
c2e6a6c
ping_interval, fmt
alexlapa Apr 8, 2019
479dcd4
Merge branch 'master' into discover-jason-api
alexlapa Apr 8, 2019
ce6d1f5
update lock
alexlapa Apr 8, 2019
6ef9c74
Merge branch 'master' into bootstrap-web-client
alexlapa Apr 8, 2019
a568ba8
fix merge
alexlapa Apr 8, 2019
f423025
fix merge
alexlapa Apr 8, 2019
0d26545
copy protocol messages
alexlapa Apr 8, 2019
eeccfc7
Merge branch 'bootstrap-web-client' into discover-jason-api
alexlapa Apr 8, 2019
f5f653b
Merge branch 'add_peer' into discover-jason-api
alexlapa Apr 8, 2019
22d3724
parse command
alexlapa Apr 8, 2019
319d732
Merge branch 'master' into discover-jason-api
alexlapa Apr 8, 2019
436e3b6
impl drop for transport, send events to subs
alexlapa Apr 9, 2019
cf6ea50
transport.send_command()
alexlapa Apr 9, 2019
d852df2
Refactoring send message from WsSession to Room use try_send
Kirguir Apr 9, 2019
ff94c99
parse event in session
alexlapa Apr 9, 2019
0618206
Add reconnect timeout parameter to config
Kirguir Apr 10, 2019
b74656f
properly pass medea events to session
alexlapa Apr 10, 2019
e2dd0f3
Merge branch 'master' into discover-jason-api
alexlapa Apr 10, 2019
3db478c
fix merge
alexlapa Apr 10, 2019
f40661f
Merge branch 'master' into add_peer
Kirguir Apr 11, 2019
63c9896
create api package
alexlapa Apr 11, 2019
fbe6664
fix imports
alexlapa Apr 11, 2019
e41a7e2
refactor session.rs
alexlapa Apr 11, 2019
24e2413
move rpc connection to module
alexlapa Apr 11, 2019
b0de9a7
minor refactor
alexlapa Apr 11, 2019
a8eb8e0
add todos
alexlapa Apr 12, 2019
baa65b4
refactor session
alexlapa Apr 12, 2019
20d9859
Merge branch 'add_peer' into discover-jason-api
alexlapa Apr 12, 2019
99c058b
refactor
alexlapa Apr 15, 2019
d708a21
Impl handler StartSignaling
Kirguir Apr 15, 2019
b498467
error handling and propagation
alexlapa Apr 15, 2019
d1f4651
error handling and propagation
alexlapa Apr 15, 2019
81ebfba
error handling and propagation
alexlapa Apr 16, 2019
ae869fd
error handling and propagation
alexlapa Apr 16, 2019
7bf48f0
Make linter happy
Kirguir Apr 16, 2019
c068a69
TryFrom<&MessageEvent> for MedeaEvent, TryFrom<&MessageEvent> for Hea…
alexlapa Apr 16, 2019
5a00dbf
js_val_to_string
alexlapa Apr 16, 2019
785b76b
create websocket wrapper
alexlapa Apr 16, 2019
32df588
refactor
alexlapa Apr 17, 2019
dbe5a93
fmt
alexlapa Apr 17, 2019
7d20f08
enable clippy for jason, fix jason lint
alexlapa Apr 17, 2019
fdc34c7
add some docs
alexlapa Apr 17, 2019
97246ca
refactor
alexlapa Apr 17, 2019
95baf6f
fix room duplication
alexlapa Apr 17, 2019
27715ec
properly drop Room
alexlapa Apr 17, 2019
2e862e0
websocket close
alexlapa Apr 17, 2019
1f8c6f6
fix msg json representation
alexlapa Apr 17, 2019
c90bcf5
properly drop room's process_msg_task
alexlapa Apr 18, 2019
5efee0a
correct drop transport
alexlapa Apr 18, 2019
f00b923
watch socket.on_error, track socket state
alexlapa Apr 19, 2019
d620dc3
fix cyclic drop
alexlapa Apr 19, 2019
eb88542
add event_listener
alexlapa Apr 23, 2019
98862d9
make clippy happy
alexlapa Apr 23, 2019
ae6fafa
cleanup debug logs
alexlapa Apr 23, 2019
4a494ff
clippy, cleanup
alexlapa Apr 23, 2019
b7a89ad
add some doc
alexlapa Apr 23, 2019
bf29c77
remove Handler<Heartbeat> for WsSession
alexlapa Apr 23, 2019
e80bec8
fix signaling_test
alexlapa Apr 23, 2019
d64d604
transport to rpc
alexlapa Apr 24, 2019
db792d8
refactor RpcClient.init
alexlapa Apr 24, 2019
7584324
refactor
alexlapa Apr 24, 2019
ad20aa1
refactor
alexlapa Apr 24, 2019
bbc6048
refactor
alexlapa Apr 24, 2019
96369c5
impl ser for ClientMsg and ServerMsg
alexlapa Apr 24, 2019
29eb658
add protocol deser, tests, run jason unit tests on make test
alexlapa Apr 25, 2019
41dece5
add protocol from jason
alexlapa Apr 25, 2019
b7de721
make clippy happy
alexlapa Apr 25, 2019
92de12d
fix tests
alexlapa Apr 25, 2019
b39c735
clippy
alexlapa Apr 25, 2019
a83de49
fix event send
alexlapa Apr 25, 2019
f349796
Merge branch 'add_peer' into discover-jason-api
alexlapa Apr 25, 2019
9a50956
fix event send
alexlapa Apr 25, 2019
e7eacbf
Merge branch 'add_peer' into discover-jason-api
alexlapa Apr 25, 2019
f753f25
connect in tests
alexlapa Apr 25, 2019
b49eec6
refactor transport.subscribe()
alexlapa Apr 26, 2019
246d395
transport futurization
alexlapa Apr 26, 2019
4af378a
format
alexlapa May 1, 2019
965256a
format
alexlapa May 1, 2019
0361e30
Impl return socket only if connection success
Kirguir May 2, 2019
91e83fd
Impl on_close handler
Kirguir May 2, 2019
59623c6
Impl on_close handler for RpcClient
Kirguir May 3, 2019
7cd3ff1
Impl on_message handler for RpcClient
Kirguir May 3, 2019
6002e2d
Create protocol package
Kirguir May 6, 2019
6c0bca3
Impl MemberMessage and RoomMessage for in and out messages in Room
Kirguir May 6, 2019
9454b0f
Impl ServerMessage for input messages in WebMessage
Kirguir May 7, 2019
fe390a7
Merge branch 'master' into discover-jason-api
Kirguir May 7, 2019
ca1feaf
Fix merge
Kirguir May 7, 2019
2671262
Add docs
Kirguir May 7, 2019
76c660f
Fix docs
Kirguir May 7, 2019
abf3d48
Remove api::client::protocol
Kirguir May 7, 2019
c50bd4e
fix lint errors
alexlapa May 7, 2019
1dab5d2
Merge branch 'master' into discover-jason-api
alexlapa May 9, 2019
c6dbd62
fix merge
alexlapa May 9, 2019
fd4c1ee
use weak link in RoomHandle
alexlapa May 10, 2019
29c89e4
refactor, extend docs
alexlapa May 12, 2019
0f51c6d
refactor
alexlapa May 12, 2019
dfa2467
refactor
alexlapa May 13, 2019
ff29c00
Add features for protocol package
Kirguir May 14, 2019
2c494de
Add webpack config for production
Kirguir May 16, 2019
a19202b
Remove impl TryFrom<MessageEvent> for ServerMsg
Kirguir May 21, 2019
1913cf7
Merge branch 'master' into optimize-wasm-size
Kirguir May 21, 2019
ad55aa3
Remove wee_alloc feature and lto
Kirguir May 21, 2019
ab6ed6d
Remove obsolete code
Kirguir May 21, 2019
31cc362
Merge branch 'master' into optimize-wasm-size
alexlapa Jul 11, 2019
019e19e
update deps locks
alexlapa Jul 11, 2019
e155905
remove cfg_if and wee_alloc
alexlapa Jul 11, 2019
60400a8
fix make test
alexlapa Jul 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
958 changes: 492 additions & 466 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ members = [
]

[profile.release]
lto = "thin"
opt-level = "s" # Tell `rustc` to optimize for small code size.

[dependencies]
actix = "0.8"
Expand Down
34 changes: 33 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
# Aliases #
###########

build: build.jason

# Resolve all project dependencies.
#
# Usage:
Expand Down Expand Up @@ -46,6 +48,34 @@ test: test.unit



##################
# Build commands #
##################

# Build Jason E2E demo in production mode.
#
# Usage:
# make build.jason

build.jason:
@rm -rf jason/e2e-demo/dist/
npm run build --prefix=jason/e2e-demo
@make opt.jason


# Optimize wasm binary.
#
# Usage:
# make opt.wasm [file=(|<wasm-file>)]

wasm-file = $(if $(call eq,$(file),),$(shell find jason/e2e-demo/dist -name '*.module.wasm'),$(file))

opt.jason:
wasm-opt $(wasm-file) -Os -d -o $(wasm-file)




##################
# Cargo commands #
##################
Expand Down Expand Up @@ -185,8 +215,10 @@ up.medea:
# .PHONY section #
##################

.PHONY: cargo cargo.fmt cargo.lint \
.PHONY: build build.jason \
cargo cargo.fmt cargo.lint \
docs docs.rust \
opt.jason \
test test.unit \
up up.coturn up.jason up.medea \
yarn
Expand Down
8 changes: 1 addition & 7 deletions jason/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,18 @@ repository = "https://github.com/instrumentisto/medea"
[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
opt-level = "s" # Tell `rustc` to optimize for small code size.

[features]
default = ["console_error_panic_hook", "wee_alloc"]
default = ["console_error_panic_hook"]

[dependencies]
console_error_panic_hook = { version = "0.1", optional = true }
futures = "0.1"
js-sys = "0.3"
macro-attr = "0.2"
medea-client-api-proto = { path = "../proto/client-api", features = ["jason"] }
newtype_derive = "0.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.3"
wee_alloc = { version = "0.4", optional = true }
[dependencies.web-sys]
version = "0.3.4"
features = [
Expand Down
4 changes: 2 additions & 2 deletions jason/e2e-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "jason-e2e-demo",
"private": true,
"scripts": {
"start": "webpack-dev-server -d --open --port 8081",
"build": "webpack"
"start": "webpack-dev-server -d --config webpack.dev.js --open --port 8081",
"build": "webpack --config webpack.prod.js"
},
"devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
const dist = path.resolve(__dirname, "dist");

module.exports = {
mode: 'development',
entry: "./js/index.js",
output: {
path: dist,
filename: "bundle.js"
},
devServer: {
contentBase: dist,
contentBase: dist
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html'
}),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, '../'),
// WasmPackPlugin defaults to compiling in "dev" profile.
// To change that, use `forceMode: 'release'`.
}),
forceMode: 'development'
})
]
};
24 changes: 24 additions & 0 deletions jason/e2e-demo/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require("path");

const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");

const dist = path.resolve(__dirname, "dist");

module.exports = {
mode: 'production',
entry: "./js/index.js",
output: {
path: dist,
filename: "bundle.js"
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html'
}),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, '../'),
forceMode: 'production'
})
]
};
19 changes: 5 additions & 14 deletions jason/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@ mod api;
mod rpc;
mod utils;

// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see:
// https://github.com/rustwasm/console_error_panic_hook#readme
#[cfg(feature = "console_error_panic_hook")]
pub use console_error_panic_hook::set_once as set_panic_hook;

#[doc(inline)]
pub use self::api::{Jason, RoomHandle};

// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[cfg(feature = "console_error_panic_hook")]
pub use console_error_panic_hook::set_once as set_panic_hook;

#[cfg(not(feature = "console_error_panic_hook"))]
pub fn set_panic_hook() {}
26 changes: 2 additions & 24 deletions jason/src/rpc/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
use std::{cell::RefCell, convert::TryFrom, rc::Rc};

use futures::future::{Future, IntoFuture};
use macro_attr::*;
use medea_client_api_proto::{ClientMsg, ServerMsg};
use newtype_derive::NewtypeFrom;
use web_sys::{CloseEvent, Event, MessageEvent, WebSocket as BackingSocket};

use crate::{
Expand Down Expand Up @@ -147,9 +145,9 @@ impl WebSocket {
inner_mut.on_message = Some(EventListener::new_mut(
Rc::clone(&inner_mut.socket),
"message",
move |msg| {
move |msg: MessageEvent| {
let parsed =
ServerMessage::try_from(&msg).map(std::convert::Into::into);
msg.data().into_serde::<ServerMsg>().map_err(WasmErr::from);
f(parsed);
},
)?);
Expand Down Expand Up @@ -217,23 +215,3 @@ impl From<&CloseEvent> for CloseMsg {
}
}
}

macro_attr! {
#[derive(NewtypeFrom!)]
pub struct ServerMessage(ServerMsg);
}

impl TryFrom<&MessageEvent> for ServerMessage {
type Error = WasmErr;

fn try_from(msg: &MessageEvent) -> Result<Self, Self::Error> {
let payload = msg
.data()
.as_string()
.ok_or_else(|| WasmErr::from_str("Payload is not string"))?;

serde_json::from_str::<ServerMsg>(&payload)
.map_err(WasmErr::from)
.map(Self::from)
}
}