Closed GirkovArpa closed 3 years ago
Turns out that document
or Window.this
simply must have a method. Any of the following prevents the segmentation fault:
document._ = function () { };
Window.this._ = function () { };
document.foo = function () { };
Window.this.foo = function () { };
Arrow functions do not solve the problem.
Oh boy. cc @c-smile
Since posting this I've learned that Sciter.JS is very prone to segmentation faults in a variety of ways. I have not reported the others assuming @c-smile would prefer to develop instead of iron out kinks.
Not sure I understand what this is all about. In particular what are you trying to solve by this: https://github.com/sciter-sdk/rust-sciter/issues/99#issuecomment-781877799
And this one:
$('#sum_async').on('click', () => {
const textboxes = $$('.sum_async');
const numbers = textboxes.map((textbox) => textbox.value);
const [a, b] = numbers;
Window.this.xcall('sum_async', a, b, function (sum) {
Window.this.modal(<info>{sum}</info>);
// segmentation fault
});
});
is very questionable at best.
Am I right that callback function here:
Window.this.xcall('sum_async', a, b, function (sum) {
Window.this.modal(<info>{sum}</info>);
// segmentation fault
});
will be called from worker (non-GUI) thread?
If "yes" then what .modal()
is supposed to do there?
Shown modal window locks current thread (normally that is main GUI thread) until user will not respond. What thread are you going to lock? And what should happen with the GUI thread at the mean time?
Thank you for clearing up the source of the issue! I suppose this is the solution:
$('#sum_async').on('click', async () => {
const textboxes = $$('.sum_async');
const numbers = textboxes.map((textbox) => textbox.value);
const [a, b] = numbers;
const sum = await sum_async(a, b);
Window.this.modal(<info>{sum}</info>);
});
function sum_async(a, b) {
return new Promise((resolve) => {
Window.this.xcall('sum_async', a, b, resolve);
});
}
Not sure I understand what this is all about. In particular what are you trying to solve by this: #99 (comment)
By pure luck I discovered that solves the segmentation fault in this particular case. I don't understand how either 😄
https://github.com/GirkovArpa/sciter-js-rust-boilerplate/blob/57e93470707b7d5688f8f6f9a134d43f1e35e122/build/assets/js/main.js#L13
Removing
document.set_title =
from the above snippet causes a segmentation fault when this code is triggered: