sciter-sdk / rust-sciter Goto Github PK
View Code? Open in Web Editor NEWRust bindings for Sciter
Home Page: https://sciter.com
License: MIT License
Rust bindings for Sciter
Home Page: https://sciter.com
License: MIT License
Hi :)
Your screenshot link is misleading:
It leads to main Go implementation.
let p = ext::SciterAPI();
| ^^^^^^^^^^^^^^ Use of undeclared type or module ext
What happen?? this is from an included example.
Building the library worked fine.
However, when running the example(s), it spits out a linking error.
Full output:
Fresh libc v0.2.16
Fresh lazy_static v0.2.1
Compiling sciter-rs v0.4.0 (file:///D:/Downloads/rust-sciter)
Running `rustc examples\minimal.rs --crate-name minimal --crate-type bin -g
--out-dir D:\Downloads\rust-sciter\target\debug\examples --emit=dep-info,link -
L dependency=D:\Downloads\rust-sciter\target\debug -L dependency=D:\Downloads\ru
st-sciter\target\debug\deps --extern libc=D:\Downloads\rust-sciter\target\debug\
deps\liblibc-1417726cb94dbc83.rlib --extern lazy_static=D:\Downloads\rust-sciter
\target\debug\deps\liblazy_static-359f5533c970cd71.rlib --extern sciter=D:\Downl
oads\rust-sciter\target\debug\libsciter.rlib`
error: linking with `link.exe` failed: exit code: 1181
note: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\li
nk.exe" "/LIBPATH:C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib
\\amd64" "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.10240.0\
\ucrt\\x64" "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\8.1\\lib\\winv6.3\\
um\\x64" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Sogomn\\.multirust\\toolchai
ns\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D
:\\Downloads\\rust-sciter\\target\\debug\\examples\\minimal.0.o" "/OUT:D:\\Downl
oads\\rust-sciter\\target\\debug\\examples\\minimal.exe" "/OPT:REF,ICF" "/DEBUG"
"/LIBPATH:D:\\Downloads\\rust-sciter\\target\\debug" "/LIBPATH:D:\\Downloads\\r
ust-sciter\\target\\debug\\deps" "/LIBPATH:C:\\Users\\Sogomn\\.multirust\\toolch
ains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib"
"D:\\Downloads\\rust-sciter\\target\\debug\\libsciter.rlib" "D:\\Downloads\\rust
-sciter\\target\\debug\\deps\\liblazy_static-359f5533c970cd71.rlib" "D:\\Downloa
ds\\rust-sciter\\target\\debug\\deps\\liblibc-1417726cb94dbc83.rlib" "C:\\Users\
\Sogomn\\.multirust\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x8
6_64-pc-windows-msvc\\lib\\libstd-39b92f95.rlib" "C:\\Users\\Sogomn\\.multirust\
\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc
\\lib\\libpanic_unwind-39b92f95.rlib" "C:\\Users\\Sogomn\\.multirust\\toolchains
\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libu
nwind-39b92f95.rlib" "C:\\Users\\Sogomn\\.multirust\\toolchains\\stable-x86_64-p
c-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librand-39b92f95.rlib
" "C:\\Users\\Sogomn\\.multirust\\toolchains\\stable-x86_64-pc-windows-msvc\\lib
\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcollections-39b92f95.rlib" "C:\\Users
\\Sogomn\\.multirust\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x
86_64-pc-windows-msvc\\lib\\librustc_unicode-39b92f95.rlib" "C:\\Users\\Sogomn\\
.multirust\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-w
indows-msvc\\lib\\liblibc-39b92f95.rlib" "C:\\Users\\Sogomn\\.multirust\\toolcha
ins\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\l
iballoc-39b92f95.rlib" "C:\\Users\\Sogomn\\.multirust\\toolchains\\stable-x86_64
-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-39b
92f95.rlib" "C:\\Users\\Sogomn\\.multirust\\toolchains\\stable-x86_64-pc-windows
-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-39b92f95.rlib" "user32
.lib" "ole32.lib" "sciter64.lib" "msvcrt.lib" "ws2_32.lib" "userenv.lib" "shell3
2.lib" "advapi32.lib" "msvcrt.lib" "compiler-rt.lib"
note: LINK : fatal error LNK1181: cannot open input file 'sciter64.lib'
error: aborting due to previous error
error: Could not compile `sciter-rs`.
Caused by:
Process didn't exit successfully: `rustc examples\minimal.rs --crate-name mini
mal --crate-type bin -g --out-dir D:\Downloads\rust-sciter\target\debug\examples
--emit=dep-info,link -L dependency=D:\Downloads\rust-sciter\target\debug -L dep
endency=D:\Downloads\rust-sciter\target\debug\deps --extern libc=D:\Downloads\ru
st-sciter\target\debug\deps\liblibc-1417726cb94dbc83.rlib --extern lazy_static=D
:\Downloads\rust-sciter\target\debug\deps\liblazy_static-359f5533c970cd71.rlib -
-extern sciter=D:\Downloads\rust-sciter\target\debug\libsciter.rlib` (exit code:
101)
I'm on Windows 7. Sciter is added to PATH and works. Newest cargo
and rustc
version.
I run the following before creating my first Sciter window:
sciter::set_options(sciter::RuntimeOptions::DebugMode(false)).unwrap();
sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SOCKET_IO as u8,
))
.unwrap();
I am still able to connect to the inspector even though I set DebugMode(false)
.
I can provide a small example if desired.
Find a way to provide access to the Sciter dll/dylib/so as dependency.
Now it is shipped as dynamic library, which must be installed manually to PATH / LIBRARY_PATH / LD_LIBRARY_PATH.
something was wrong when i used rust(64) to build examples.
$ cargo run --example minimal
Running target\debug\examples\minimal.exe
error: Process didn't exit successfully: target\debug\examples\minimal.exe
(exit code: 3221225477)
Segmentation fault
Hi there, I get some data from a specific api, pass them as string to sciter, and update these data in sciter tables. In EventHandler, I write a function for doing this in a loop mode.
But memory leak occurred, memory usage would increase by about 0.1mb/sec.
Is this normal? If not, any idea how to fix it?
Thanks a lot.
There is a console window, can it be hiden?
So, here is a story.
Travis has only Precise and Trusty LTS versions (12 & 14) and Sciter does not work in there by default.
$ ./usciter
./usciter: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: versionCXXABI_1.3.8
not found
./usciter: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: versionGLIBCXX_3.4.21
not found
$ ls /usr/lib/x86_64-linux-gnu/libstdc++.so.*
/usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19
$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep CXXABI
CXXABI_1.3
CXXABI_1.3.1
CXXABI_1.3.2
CXXABI_1.3.3
CXXABI_1.3.4
CXXABI_1.3.5
CXXABI_1.3.6
CXXABI_1.3.7
CXXABI_TM_1
So, Ubuntu 14 contains libstdc++ 6.0.19 by default, while Ubuntu 16 or higher 6.0.24:
$ ls /usr/lib/x86_64-linux-gnu/libstdc++.so.*
/usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24
**$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep CXXABI
CXXABI_1.3
CXXABI_1.3.1
CXXABI_1.3.2
CXXABI_1.3.3
CXXABI_1.3.4
CXXABI_1.3.5
CXXABI_1.3.6
CXXABI_1.3.7
CXXABI_1.3.8
CXXABI_1.3.9
CXXABI_1.3.10
CXXABI_1.3.11
CXXABI_TM_1
CXXABI_FLOAT128
It looks like we need a newer libstdc++ version. Right? Partly.
Let's try to install it:
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install libstdc++-7-dev
$ ls /usr/lib/x86_64-linux-gnu/libstdc++.so.*
/usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24
Now we have 6.0.24 and Sciter works: ./usciter
shows its fancy window.
But: the rust-sciter still can't be compiled:
$ cargo build --example first
...
error: linking withcc
failed: exit code: 1
= note: ./libsciter-gtk-64.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long&, unsigned long)@GLIBCXX_3.4.21'
collect2: error: ld returned 1 exit status
Whereas libstdc++ does contain the required GLIBCXX:
$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_DEBUG_MESSAGE_LENGTH
And now I am out of ideas.
I am still able to compile rust-sciter with a trick with RUSTFLAGS (export RUSTFLAGS='-C link-arg=-Wl,--unresolved-symbols=ignore-in-shared-libs'
), but it will crash eventually during cargo test
.
Apparently, GCC has introduced a so-called Dual ABI in 5.1: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html and most of issues with GLIBCXX are pointed to that story with advice to update GCC / update libstdc++ / recompile with -D_GLIBCXX_USE_CXX11_ABI=0 and so on.
Nothing helps here, of course, we don't have C++ code to recompile.
The only thing I have noticed in differences between Ubuntu 14 and 16: if I update GCC, it will show a suspicious flag in its configuration: --disable-libstdcxx-dual-abi
(gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1~14.04)) while GCC 7 on 16 does not have it (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2) ).
sciter::Value
: remove indexing (works via a hack now)sciter::Value::isolate
should be unsafe
s2w
: return a single value only, s2wn
returns value and lengthwindow::with_size
and K°: use window::Builder
instead.[width, height]
(why? totally forgot now)std::error::Error
nowWindow::load_html
and Window::load_file
should return bool
(even better - a proper Result
)Window::load_html
and Window::load_file
should return a proper Result
Window::load_file
should accept AsPath
traitdom::Element
:: get_value
, get_hwnd
, attribute
, get_style_attribute
should return resultdom::Element
:: from_window
, from_point
, from_focus
, from_highlighted
should return Result<Option<Element>>
dom::Element
:: get_tag
, get_text
should return a proper resultI downloaded the Sciter SDK, copied the sciter.dll for win64 and generated the sciter.lib file from it. I cloned rust-sciter and ran the examples, all worked except first
which crashed:
Running `target\debug\examples\first.exe`
calling SciterAPI x64
getting abi version
sciter abi version: 0
sciter class name: H-SMILE-CHILD
sciter version: 4.1.1.5703 [4, 1, 1, 5703]
error: process didn't exit successfully: `target\debug\examples\first.exe` (exit code: 3221225477)
Unhandled exception at 0x00007FFB36A93499 (sciter.dll) in first.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
So it's reading from a null pointer for some reason, after the last line of main, weird.. Any idea how to fix this? (I'm on Win8.1 btw)
I can't seem to get this to work, is it unimplemented or could you provide an example?
I've tried:
<picture src="icon.png" />
<div id="main"></div>
with css:
#main {
height: 100%;
width: 100%;
background-image: url(background.png);
}
Both ways to load images do not seem to work.
cargo run --example minimal
just output error message:
warning: unused manifest key: badges.appveyor.repository
warning: unused manifest key: package.categories
warning: unused manifest key: package.categories
warning: unused manifest key: package.categories
warning: unused manifest key: package.categories
Compiling sciter-rs v0.4.16 (file:///Volumes/src/git/rust/rust-sciter)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-m64" "-L" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Volumes/src/git/rust/rust-sciter/target/debug/examples/minimal-049750bad57ec635.0.o" "-o" "/Volumes/src/git/rust/rust-sciter/target/debug/examples/minimal-049750bad57ec635" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Volumes/src/git/rust/rust-sciter/target/debug/deps" "-L" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libsciter-e229de1bcb7d347a.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/liblazy_static-4345d0db7d7e9b05.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libobjc_foundation-cd7bec3c0f31e91a.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libblock-81bb5816adb186e4.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libobjc_id-f01a1943dfb75bb9.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libobjc-2834ac60b01b7699.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/libmalloc_buf-826d6968858cdff6.rlib" "/Volumes/src/git/rust/rust-sciter/target/debug/deps/liblibc-6451aa7d8103c93e.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-f1544d51c14ee547.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-0973ad751bdffbae.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-30637a1739b412eb.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librand-6ce8560490ee791c.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcollections-77c40ab2fac1172e.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-40208fb59386bff5.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-4b56f5c0b7251555.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-cba64299ce12485f.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_unicode-a98ebaa82aaee358.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-cfc94a4f91ad8df0.rlib" "/Users/tony/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-51cf9867f46a760f.rlib" "-l" "sciter-osx-64" "-framework" "Foundation" "-l" "System" "-l" "objc" "-l" "objc" "-l" "objc" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m"
= note: ld: library not found for -lsciter-osx-64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
error: Could not compile `sciter-rs`.
To learn more, run the command again with --verbose.
Because of 4.2.5.0 disabling some unsafe features by default, the minimal example now
Being new to Sciter I had to stare at some really opaque error messages for a while (which don't even show up by default because #![windows_subsystem = "windows"]) to figure out what's going on.
Do we want to add
sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SYSINFO as u8 | // Enables Sciter.machineName()
sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_FILE_IO as u8 | // Enables opening file dialog
sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SOCKET_IO as u8)).unwrap(); // Enables connecting to inspector
or should we just remove these things (file opener, machineName(), inspector) from the minimal.rs example.
Personally think showing this early is pretty important, because Sciter's own documentation don't seem to show any of this, and the error messages all just say the functions are undefined.
I'll probably make a PR for this.
As in #46.
Because currently it looks awful:
let mut frame = sciter::Window::with_size((600, 400), sciter::window::Flags::main_window(false));
So it does not want to become foreground.
Hi,
I can not type anything into text fields, even though I can paste values into them.
My simple HTML:
<html>
<form>
Text: <input type="text">
</form>
</html>
The main.rs:
#[macro_use]
extern crate sciter;
fn main() {
let mut frame = sciter::Window::new();
let html = include_bytes!("main.html");
frame.load_html(html, None);
frame.run_app(true);
}
The test environment:
Something like this:
#[derive(ScriptHandler)]
struct EventHandler;
impl EventHandler {
#[script]
fn sum(&self, a: i32, b: i32) -> i32 { a + b }
#[script(name="div")]
fn custom_div(&self, a: i32, b: i32) -> i32 { a / b }
}
However it does not seem possible. Apparently, Macros 1.1 allow only type-level attributes.
I notice you intend to release rust-sciter
under an MIT license. (And Sciter Engine has it's own separate license).
The README links to https://opensource.org/licenses/MIT, but if you go there you'll notice it's just a template. In my opinion, the problem is specifically that the copyright notice is incomplete in the template.
To illustrate the problem another way. When I comply with the MIT license and include the copyright, should I include Copyright <YEAR> <COPYRIGHT HOLDER>
literally in my project? I don't know know who else to list as the copyright holder. I would expect to use an actual year, not <YEAR>
, and ascribe the copyright to a person or organization instead of COPYRIGHT HOLDER
.
I am not a lawyer though, so maybe my understanding is wrong.
Thanks for your consideration of this and for Sciter, I'm excited to use it.
trying to run the example in step 3 gives me this error on mac, any ideas?
cargo run --example minimal
Compiling sciter-rs v0.4.0
src/window.rs:82:33: 82:37 error: mismatched types:
expected platform::windows::OsWindow
,
found *mut capi::sctypes::_HWINDOW
(expected struct platform::windows::OsWindow
,
found *-ptr) [E0308]
src/window.rs:82 Window { base: OsWindow::from(hwnd), host: Rc::new(Host::attach(hwnd)) }
^~~~
src/window.rs:82:33: 82:37 help: run rustc --explain E0308
to see a detailed explanation
error: aborting due to previous error
Could not compile sciter-rs
.
This line in my code panics:
sciter::set_options(sciter::RuntimeOptions::UxTheming(true)).unwrap();
It panics with the following message:
thread 'main' panicked at 'called
Result::unwrap()on an
Err value: ()', src/libcore/result.rs:999:5
I see the following code is related to this error:
/// Set various sciter engine global options, see the [`RuntimeOptions`](enum.RuntimeOptions.html).
pub fn set_options(options: RuntimeOptions) -> std::result::Result<(), ()> {
use RuntimeOptions::*;
use capi::scdef::SCITER_RT_OPTIONS::*;
let (option, value) = match options {
ConnectionTimeout(ms) => (SCITER_CONNECTION_TIMEOUT, ms as usize),
OnHttpsError(behavior) => (SCITER_HTTPS_ERROR, behavior as usize),
// GpuBlacklist(json) => (SCITER_SET_GPU_BLACKLIST, json.as_bytes().as_ptr() as usize),
InitScript(script) => (SCITER_SET_INIT_SCRIPT, script.as_bytes().as_ptr() as usize),
ScriptFeatures(mask) => (SCITER_SET_SCRIPT_RUNTIME_FEATURES, mask as usize),
GfxLayer(backend) => (SCITER_SET_GFX_LAYER, backend as usize),
DebugMode(enable) => (SCITER_SET_DEBUG_MODE, enable as usize),
UxTheming(enable) => (SCITER_SET_UX_THEMING, enable as usize),
LibraryPath(path) => {
return set_library(path).map_err(|_|());
}
};
let ok = (_API.SciterSetOption)(std::ptr::null_mut(), option, value);
if ok != 0 {
Ok(())
} else {
Err(())
}
}
The value of ok
ends up being 0
, and so the Err(())
is returned. I'm not sure where to look for documentation on the Sciter C++ API, but the set option call is returning 0, what does that mean?
The error occurs on Linux (GTK / Wayland), but not on Windows.
Hi, @pravic.
When are you gonna implement fire_event function for Element?
This segfault can be easily reproduced by unzipping the minimal project I'm attaching, and typing cargo run
.
This minimal application will display
<html>
<head>
<title>Segfault when loading main.css and an anchor is present</title>
<style src="main.css" />
</head>
<body>
<h1>Minimal Sciter Application</h1>
<p><a href="any_url">Sciter SDK</a></p>
</body>
</html>
and the main.css
file is send to Sciter using on_data_load
in the main.rs
file.
Oddly enough:
<style src="main.css" />
...
<a href="any_url">Sciter SDK</a>
Via features I think.
How to create a child window from a given parent HWND
?
Like this: https://sciter.com/tag/child-window/
os:
Windows 10, 64bit.
cargo:
C:\Users\liang>rustc --version --verbose
rustc 1.25.0 (84203cac6 2018-03-25)
binary: rustc
commit-hash: 84203cac67e65ca8640b8392348411098c856985
commit-date: 2018-03-25
host: x86_64-pc-windows-msvc
release: 1.25.0
LLVM version: 6.0
sciter:
https://github.com/c-smile/sciter-sdk
PS E:\github\rust-sciter> cargo run --example threads
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target\debug\examples\threads.exe`
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: INCOMPATIBLE_TYPE', libcore\result.rs:945:5
stack backtrace:
0: 0x7ff621732aea - std::sys::windows::backtrace::unwind_backtrace
at C:\projects\rust\src\libstd\sys\windows\backtrace\mod.rs:65
1: 0x7ff621732aea - std::sys_common::backtrace::_print
at C:\projects\rust\src\libstd\sys_common\backtrace.rs:71
2: 0x7ff6217359c2 - std::sys_common::backtrace::print
at C:\projects\rust\src\libstd\sys_common\backtrace.rs:59
3: 0x7ff6217359c2 - std::panicking::default_hook::{{closure}}
at C:\projects\rust\src\libstd\panicking.rs:380
4: 0x7ff621735634 - std::panicking::default_hook
at C:\projects\rust\src\libstd\panicking.rs:396
5: 0x7ff621735f29 - std::panicking::rust_panic_with_hook
at C:\projects\rust\src\libstd\panicking.rs:576
6: 0x7ff621735db0 - std::panicking::begin_panic<alloc::string::String>
at C:\projects\rust\src\libstd\panicking.rs:537
7: 0x7ff621735c91 - std::panicking::begin_panic_fmt
at C:\projects\rust\src\libstd\panicking.rs:521
8: 0x7ff621735c01 - std::panicking::rust_begin_panic
at C:\projects\rust\src\libstd\panicking.rs:497
9: 0x7ff62173a6bc - core::panicking::panic_fmt
at C:\projects\rust\src\libcore\panicking.rs:71
10: 0x7ff62170162a - core::result::unwrap_failed<sciter::capi::scvalue::VALUE_RESULT>
at C:\projects\rust\src\libcore\macros.rs:23
11: 0x7ff6217012b5 - core::result::Result<sciter::value::Value, sciter::capi::scvalue::VALUE_RESULT>::unwrap<sciter::value::Value,sciter::capi::scvalue::VALUE_RESULT>
at C:\projects\rust\src\libcore\result.rs:782
12: 0x7ff621703a75 - threads::{{impl}}::exec_task::{{closure}}
at E:\github\rust-sciter\examples\threads.rs:22
13: 0x7ff621706945 - std::sys_common::backtrace::__rust_begin_short_backtrace<closure,()>
at C:\projects\rust\src\libstd\sys_common\backtrace.rs:136
14: 0x7ff621702389 - std::thread::{{impl}}::spawn::{{closure}}::{{closure}}<closure,()>
at C:\projects\rust\src\libstd\thread\mod.rs:406
15: 0x7ff621705df5 - std::panic::{{impl}}::call_once<(),closure>
at C:\projects\rust\src\libstd\panic.rs:293
16: 0x7ff621704363 - std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()>
at C:\projects\rust\src\libstd\panicking.rs:479
17: 0x7ff621738241 - panic_unwind::__rust_maybe_catch_panic
at C:\projects\rust\src\libpanic_unwind\lib.rs:102
18: 0x7ff621704257 - std::panicking::try<(),std::panic::AssertUnwindSafe<closure>>
at C:\projects\rust\src\libstd\panicking.rs:458
19: 0x7ff621705e40 - std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()>
at C:\projects\rust\src\libstd\panic.rs:358
20: 0x7ff6217021ca - std::thread::{{impl}}::spawn::{{closure}}<closure,()>
at C:\projects\rust\src\libstd\thread\mod.rs:405
21: 0x7ff6217023ef - alloc::boxed::{{impl}}::call_box<(),closure>
at C:\projects\rust\src\liballoc\boxed.rs:788
22: 0x7ff6217375ae - alloc::boxed::{{impl}}::call_once
at C:\projects\rust\src\liballoc\boxed.rs:798
23: 0x7ff6217375ae - std::sys_common::thread::start_thread
at C:\projects\rust\src\libstd\sys_common\thread.rs:24
24: 0x7ff6217375ae - std::sys::windows::thread::{{impl}}::new::thread_start
at C:\projects\rust\src\libstd\sys\windows\thread.rs:55
25: 0x7ffb6e0e1fe3 - BaseThreadInitThunk
26: 0x7ffb6e39efb0 - RtlUserThreadStart
When I tried to launch examples(multiple), I got the following error messages.
$ cargo run --example threads
Finished dev [unoptimized + debuginfo] target(s) in 0.3 secs
Running `target/debug/examples/threads`
window::create(rect (0, 0, 1200, 900), flags 96, parent 0x0
window::create with flags 96
view 0x7f9722432bb0
view 0x7f9722432bb0 -> window 0x7f9722455140
fatal runtime error: allocator memory exhausted
[1] 981 illegal hardware instruction cargo run --example threads
I have no idea why. I just wanted to learn this library using rust.
I'm using macOS High Sierra 10.13.4, rustc 1.26.0-nightly (e5277c145 2018-03-28) and fresh sciter-sdk.
I recently updated my sciter-sdk and I am unable to connect to the inspector. My code is unchanged. I was previously able to connect to the inspector and now I am not able to. Unfortunately, I didn't take note of what version of the SDK I had previously, but it was a few months old I think.
EDIT: I should add that I am using Sciter version 4.2.7.5
on Linux-5.0.5-200.fc29.x86_64
Need check why is so.
Full log:
creating some elments
attached to progress#id1
button click on target progress#id1
starting timer
timer 1 tick on progress#id1
timer 1 tick on progress#id1
timer 1 tick on progress#id1
timer 1 tick on progress#id1
timer 1 tick on progress#id1
button click on target progress#id1
stopping timer
-- close window --
warning! null element for HANDLE_BEHAVIOR_EVENT
warning! null element for HANDLE_BEHAVIOR_EVENT:ANIMATION
warning! null element for HANDLE_BEHAVIOR_EVENT
warning! null element for HANDLE_BEHAVIOR_EVENT:ANIMATION
warning! null element for HANDLE_BEHAVIOR_EVENT
warning! null element for HANDLE_BEHAVIOR_EVENT:DOCUMENT_CLOSE
warning! null element for HANDLE_BEHAVIOR_EVENT
warning! null element for HANDLE_BEHAVIOR_EVENT:DOCUMENT_CLOSE
detaching from progress#id1
detaching from None
Hello !
I've just build DOM example (https://github.com/sciter-sdk/rust-sciter/blob/master/examples/dom.rs) and run it, but all i see is blank white window.
I also tried to change from load_file to load_html to load site from memory( i've coppied html-code of site to minimal.htm) :
let html = include_bytes!("minimal.htm");
frame.load_html(html, Some("example://minimal.htm"));
And it worked fine. So it seems like rust-sciter cannot load internet web page.
Site is available, PC has internet connection. OS : ArchLinux
I also tried to run as root but no success.
The package name should be sciter
, not sciter-rs
. Package and crate names should not include a rust-
prefix or -rs
suffix, because we already know it’s Rust.
(The crate name is already sciter
, which is correct; but you should basically never specify lib.name in Cargo.toml; it’s almost always the wrong thing to do.)
Is there a way to load files like how the html file is loaded in the examples.
let mut frame = sciter::Window::new();
frame.load_html(html_vec, Some("some/path"));
But for other files like fonts or css files?
In more recent versions of Sciter, sciter::Window::new().load_file(url)
seems to be broken when using characters in the url
that get converted to their special counterpart e.g. spacebar
to %20
.
For example the following Warning pops up:
WARNING:DOM: failed to load "/home/sonny/git/Launcher/target/release/new%20theme/frontpage.htm" file, error=2
This is atleast the case for the sciter releases from 6th of june and 8th of june. Both for windows and linux.
Sciter itself can load the files fine (tested using usciter, both from command line and using the interface)
I don’t know exactly where the fault may be, but when I run the examples they’re all low DPI on my 200% scaling factor Windows device. I know that Sciter itself must be capable of running high-DPI, because I tried out the HTML Notepad app and it’s scaled properly.
I noticed that window.run_app()
will run the main loop for the Sciter app and block until Sciter ends. Now I would like to run my own functions in the main loop as well, to intercept events and manipulate the Sciter host from my Rust application. How would I go about doing this? I can't seem to find anything about that in the documentation.
i see theres a branch for that... any idea when it will be done & merged -or..?
in the meantime, thanks for this incredible lib :)
It seems currently there is no such feature. I call tiscript function to draw the text, but this method takes a lot more cpu. So hopefully this feature could be supported at your early convenience. Thanks.
I cannot use methods which return Result in dispatch_script_call macro. Maybe implement From trait for Value for such case? For example, on error convert error to string and return Value::error(...).
Hi,
I'm trying out Sciter as a UI engine for my Rust app that runs on macOS.
I need a system menu, so I use cocoa
crate to create a NSApplication
and a NSWindow
.
Unfortunately, I can't make sciter::Window::attach
to work: it crashes every time I call it.
The code is pretty much as follows (menu creation is omitted):
use sciter;
use cocoa::base::nil;
use cocoa::foundation::NSAutoreleasePool;
use cocoa::appkit::{NSApplication, NSWindow};
fn main() {
unsafe {
let _pool = NSAutoreleasePool::new(nil);
}
let app = create_app();
let window = add_window();
let mut frame = sciter::Window::attach(window);
frame.load_html(br#"<html><body>Hello world!</body></html>"#, Some("x:main"));
unsafe {
app.run();
}
}
fn create_app() -> cocoa::base::id {
unsafe {
let app = cocoa::appkit::NSApp();
app.setActivationPolicy_(cocoa::appkit::NSApplicationActivationPolicyRegular);
app
}
}
fn add_window() -> sciter::types::HWINDOW {
unsafe {
let window = NSWindow::alloc(nil).initWithContentRect_styleMask_backing_defer_(
cocoa::foundation::NSRect::new(cocoa::foundation::NSPoint::new(0., 0.), cocoa::foundation::NSSize::new(300., 200.)),
cocoa::appkit::NSWindowStyleMask::NSTitledWindowMask,
cocoa::appkit::NSBackingStoreBuffered,
cocoa::base::NO
).autorelease();
window.center();
window.makeKeyAndOrderFront_(nil);
window.contentView() as _
}
}
It doesn't matter if I try to pass window
itself or window.contentView()
- it still crashes on sciter::Window::attach
line with the following message:
2019-08-29 16:03:10.938 sciter-app[28447:3486458] -[NSView engine]: unrecognized selector sent to instance 0x7ff96f830190
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21
Could you please help me to make it work? Thanks!
I'm trying implement live reload and can't do that. Because separate thread must be spawned for directory watching and sciter::Window cannot be shared between threads. Any suggestions?
Hello all,
error[E0277]: the trait bound `for<'r> (): std::ops::Fn<(&'r [sciter::Value],)>` is not satisfied
--> src\main.rs:12:2
|
12 | dispatch_script_call! (
| _____^
13 | | fn do_tag_search(String);
14 | | );
| |______^ the trait `for<'r> std::ops::Fn<(&'r [sciter::Value],)>` is not implemented for `()`
|
= note: required because of the requirements on the impl of `std::convert::From<()>` for `sciter::Value`
= note: required by `std::convert::From::from`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
#[macro_use] extern crate sciter;
struct EventHandler;
impl EventHandler {
fn do_tag_search(&self, search: String) {
println!("Requested tag search: {}", search);
}
}
impl sciter::EventHandler for EventHandler {
dispatch_script_call! (
fn do_tag_search(String);
);
}
fn main() {
let handler = EventHandler { };
let mut frame = sciter::Window::new();
frame.event_handler(handler);
frame.load_file("src/main.html");
frame.run_app();
}
I have no idea what's going on; I suspect something's changed that's not shown in the examples preventing this from working. Any ideas?
I think the native sciter sdk(c++ library) is multiple thread friendly. However, it sucks when I use this rust binding in a multiple thead situation.
Currently both sciter::Window
and sciter::Host
are not Sync
or Send
. Do you have any plan to change this?
Though it is used only here and it is overrideable:
Lines 85 to 89 in 25eb781
I have the following code:
use rusqlite::Connection;
use sciter::w2s;
struct HostHandler {
app_archive: sciter::host::Archive,
}
impl sciter::host::HostHandler for HostHandler {
fn on_data_load(
&mut self,
data: &mut sciter::host::SCN_LOAD_DATA,
) -> Option<sciter::host::LOAD_RESULT> {
let requested_uri = w2s!(data.uri);
eprintln!("Loading: {:?}", &requested_uri[7..]);
if requested_uri.starts_with("file://") {
let desired_app_archive_file = &requested_uri[7..];
if let Some(bytes) = self.app_archive.get(desired_app_archive_file) {
eprintln!("Loading: {:?}", self.app_archive.get(&requested_uri[7..]));
eprintln!(
"{}",
String::from_utf8_lossy(self.app_archive.get(&requested_uri[7..]).unwrap())
);
self.data_ready(data.hwnd, &requested_uri, bytes, None);
}
}
Some(sciter::host::LOAD_RESULT::LOAD_MYSELF)
}
}
pub fn app_main(_db_conn: &Connection) {
setup_sciter();
let app_archive = sciter::host::Archive::open(APP_ARCHIVE).unwrap();
let mut main_window = sciter::Window::new();
main_window.sciter_handler(HostHandler { app_archive });
main_window.load_file("main.htm");
main_window.run_app();
}
fn setup_sciter() {
sciter::set_options(sciter::RuntimeOptions::DebugMode(true)).unwrap();
sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SOCKET_IO as u8,
))
.unwrap();
}
const APP_ARCHIVE: &[u8] = include_bytes!(env!("APP_ARCHIVE"));
The output when I run this code is:
Loading: "main.htm"
Loading: Some([60, 104, 116, 109, 108, 62, 10, 32, 32, 32, 32, 60, 104, 101, 97, 100, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 116, 105, 116, 108, 101, 62, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 60, 47, 116, 105, 116, 108, 101, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 115, 99, 114, 105, 112, 116, 32, 116, 121, 112, 101, 61, 34, 116, 101, 120, 116, 47, 116, 105, 115, 99, 114, 105, 112, 116, 34, 32, 115, 114, 99, 61, 34, 120, 121, 122, 34, 32, 47, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 115, 99, 114, 105, 112, 116, 32, 116, 121, 112, 101, 61, 34, 116, 101, 120, 116, 47, 116, 105, 115, 99, 114, 105, 112, 116, 34, 32, 115, 114, 99, 61, 34, 115, 114, 99, 47, 115, 99, 105, 116, 101, 114, 47, 109, 46, 116, 105, 115, 34, 32, 47, 62, 10, 32, 32, 32, 32, 60, 47, 104, 101, 97, 100, 62, 10, 32, 32, 32, 32, 60, 98, 111, 100, 121, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 10, 32, 32, 32, 32, 60, 47, 98, 111, 100, 121, 62, 10, 60, 47, 104, 116, 109, 108, 62, 10])
<html>
<head>
<title>Hello World!</title>
<script type="text/tiscript" src="xyz" />
<script type="text/tiscript" src="src/sciter/m.tis" />
</head>
<body>
Hello World!
</body>
</html>
The archive is clearly working, but when I run this code it just shows a blank Sciter window, as though the file load never did anything.
I believe my code here is self contained, you just have to change app_main
to main
(and I guess get rid of the database connection parameter that's never used).
Subj
Apologies if this is an incorrect issue, I'm still new to Rust. I am trying to return an array to tiscript from a callback. I get the following error:
error[E0277]: the trait bound `for<'r> [u8; 61452]: std::ops::Fn<(&'r [sciter::Value],)>` is not satisfied
--> src\main.rs:28:5
|
28 | / dispatch_script_call!
29 | | {
30 | | fn get_gfx_buffer();
31 | | }
| |_____^ the trait `for<'r> std::ops::Fn<(&'r [sciter::Value],)>` is not implemented for `[u8; 61452]`
|
= note: required because of the requirements on the impl of `std::convert::From<[u8; 61452]>` for `sciter::Value`
= note: required by `std::convert::From::from`
= note: this error originates in a macro outside of the current crate
error[E0277]: the trait bound `for<'r> [u8; 61452]: std::ops::FnOnce<(&'r [sciter::Value],)>` is not satisfied
--> src\main.rs:28:5
|
28 | / dispatch_script_call!
29 | | {
30 | | fn get_gfx_buffer();
31 | | }
| |_____^ the trait `for<'r> std::ops::FnOnce<(&'r [sciter::Value],)>` is not implemented for `[u8; 61452]`
|
= note: required because of the requirements on the impl of `std::convert::From<[u8; 61452]>` for `sciter::Value`
= note: required by `std::convert::From::from`
= note: this error originates in a macro outside of the current crate
error: aborting due to previous error(s)
Here's the code that causes this:
static mut gfx_buffer: [[u32; 256]; 240] = [[0; 256]; 240];
struct Handler;
impl Handler
{
fn get_gfx_buffer(&self) -> [u8; 256*240+12]
{
// unroll gfx_buffer into the appropriate format
[0u8; 61452]
}
}
impl sciter::EventHandler for Handler
{
dispatch_script_call!
{
fn get_gfx_buffer();
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.