sciter-sdk / go-sciter

Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development
https://sciter.com
2.58k stars 267 forks source link

'failed to load "./index.html" file, error=2' in MACOS #132

Open b1gcat opened 6 years ago

b1gcat commented 6 years ago

Code as follows:

if err := w.LoadFile("./index.html"); err != nil { logger.Fatal(err.Error()) }

Also, i test go-sciter example(simple), i got same error.

Did i missing something?

b1gcat commented 6 years ago

My app works fine on windows, but not mac os, it seems resource path problem, is there some way to fix it?

More information:

1) Bin and index.html in the same directory. 2) I tried to load index.html with abs path, but i failed to load next other resource in the index.html.

MACOS:

OS: 10.11.6 GO: 1.10 SDK: latest. No Wmware.

b1gcat commented 6 years ago

well, i write all resouce in one html, and use abs path, it works fine. But why it happen.

:(

pravic commented 6 years ago

If the simple fails, then something is definitely wrong. Have you tried some previous sciter library version?

b1gcat commented 6 years ago

Have you tried some previous sciter library version? not yet.

Pls check if i use collectly:

xxx-iMac:simple iMac$ ls
sciter-osx-64.dylib simple          simple.go       simple.html
xxx-iMac:simple iMac$ ./simple 
Segmentation fault: 11

and open it without terminal:

xxx-iMac:~ iMac$ /Users/xx/xx/src/github.com/sciter-sdk/go-sciter/examples/simple/simple ; exit;
failed to load "simple.html" file, error=2
pravic commented 6 years ago

Oh, the segfault makes it even more interesting. Could you check with gdb/lldb what's going on in there?

b1gcat commented 6 years ago

lldb:

bt
    frame #47566: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47567: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47568: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47569: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47570: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47571: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47572: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47573: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47574: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47575: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47576: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47577: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47578: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47579: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47580: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47581: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47582: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47583: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47584: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47585: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47586: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47587: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47588: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47589: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47590: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47591: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47592: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47593: 0x000000000654df31 sciter-osx-64.dylib`xgl::application::get_supported_font_family(tool::ustring const&) + 1253
    frame #47594: 0x00000000063deafa sciter-osx-64.dylib`html::view::get_font(html::style*) + 88
    frame #47595: 0x000000000672ac8a sciter-osx-64.dylib`osx::text_analysis::generate_results(osx::view&, html::element*, html::tflow::text_flow&, tool::slice<tool::handle<html::node> >) + 908
    frame #47596: 0x000000000672d264 sciter-osx-64.dylib`osx::view::setup_text_flow(html::element*, html::tflow::text_flow&, tool::slice<tool::handle<html::node> >) + 84
    frame #47597: 0x00000000064c8742 sciter-osx-64.dylib`html::tflow::text_flow::setup(html::view&, html::element*, tool::slice<tool::handle<html::node> >) + 174
    frame #47598: 0x00000000061b05bb sciter-osx-64.dylib`html::text_block::init(html::view&, tool::slice<tool::handle<html::node> >) + 91
    frame #47599: 0x00000000061b1cc3 sciter-osx-64.dylib`html::text_block::setup_on(html::view&, html::element*, tool::slice<tool::handle<html::node> >) + 483
    frame #47600: 0x00000000062e4a97 sciter-osx-64.dylib`html::element::setup_layout(html::view&) + 2001
    frame #47601: 0x00000000062abbeb sciter-osx-64.dylib`html::element::check_layout(html::view&) + 129
    frame #47602: 0x0000000006169cc5 sciter-osx-64.dylib`html::block::layout_data::push(html::view&, html::element*, html::element*) + 195
    frame #47603: 0x00000000062e4975 sciter-osx-64.dylib`html::element::setup_layout(html::view&) + 1711
    frame #47604: 0x00000000062abbeb sciter-osx-64.dylib`html::element::check_layout(html::view&) + 129
    frame #47605: 0x0000000006169cc5 sciter-osx-64.dylib`html::block::layout_data::push(html::view&, html::element*, html::element*) + 195
    frame #47606: 0x00000000064f88e5 sciter-osx-64.dylib`html::document::setup_layout(html::view&) + 383
    frame #47607: 0x00000000062abbeb sciter-osx-64.dylib`html::element::check_layout(html::view&) + 129
    frame #47608: 0x00000000065021c2 sciter-osx-64.dylib`html::document::measure(html::view&, gool::geom::size_t<int>) + 48
    frame #47609: 0x00000000063da156 sciter-osx-64.dylib`html::view::load_html(tool::slice<unsigned char>, tool::string const&, unsigned int) + 512
    frame #47610: 0x00000000063ddbfa sciter-osx-64.dylib`html::view::load_url(tool::string const&, bool) + 178
    frame #47611: 0x00000000064d8806 sciter-osx-64.dylib`std::__1::__function::__func<SciterLoadFile_api(void*, char16_t const*)::$_0, std::__1::allocator<SciterLoadFile_api(void*, char16_t const*)::$_0>, bool ()>::operator()() + 24
    frame #47612: 0x00000000064d850b sciter-osx-64.dylib`SciterLoadFile_api(void*, char16_t const*) + 288
    frame #47613: 0x000000000409d591 simple`_cgo_1a21f7eb39dd_Cfunc_SciterLoadFile + 33
    frame #47614: 0x00000000040505c0 simple`runtime.asmcgocall + 112
    frame #47615: 0x000000000409610a simple`github.com/sciter-sdk/go-sciter._Cfunc_SciterLoadFile + 74
    frame #47616: 0x0000000004099d50 simple`github.com/sciter-sdk/go-sciter.(*Sciter).LoadFile.func1 + 96
    frame #47617: 0x00000000040972b4 simple`github.com/sciter-sdk/go-sciter.(*Sciter).LoadFile + 84
    frame #47618: 0x000000000409c51d simple`main.main + 173
    frame #47619: 0x000000000402a812 simple`runtime.main + 530
too many ...
here is a running process, kill it and restart?: [Y/n] y
Process 58794 exited with status = 9 (0x00000009) 
Process 58835 launched: './simple' (x86_64)
Process 58835 stopped
* thread #1: tid = 0x15caee, 0x0000000006107e36 sciter-osx-64.dylib`int tool::match<char16_t>(tool::slice<char16_t>, char16_t const*) + 44, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x7fff5f3fffa8)
    frame #0: 0x0000000006107e36 sciter-osx-64.dylib`int tool::match<char16_t>(tool::slice<char16_t>, char16_t const*) + 44
sciter-osx-64.dylib` tool::m::match<char16_t>:
->  0x6107e36 <+44>: movq   %rsi, (%rax)
    0x6107e39 <+47>: movq   (%r12), %r15
    0x6107e3d <+51>: xorl   %r13d, %r13d
    0x6107e40 <+54>: xorl   %r14d, %r14d
pravic commented 6 years ago

cc @c-smile It looks like an infinite recursion.

c-smile commented 6 years ago

What version of Sciter is that?

b1gcat commented 6 years ago

What version of Sciter is that?

4.1.5.5856

b1gcat commented 6 years ago

4.0.8 works good.

https://raw.githubusercontent.com/c-smile/sciter-sdk/aa2c7a1f9128c1a846e6fd6c6ab4f4172c4ccea5/bin.osx/sciter-osx-64.dylib

c-smile commented 6 years ago

Can I get that simple.html where the problem is reproducible? Appears as problem with font declarations.

pravic commented 6 years ago

Andrew: https://github.com/sciter-sdk/go-sciter/blob/master/examples/simple/simple.html

c-smile commented 6 years ago

I do not see any problems on Mac with that file in sciter.app . What about any other .html file from SDK?

b1gcat commented 6 years ago

After w.Loadfile(xxx.html), all say: ./xxxx Segmentation fault: 11

Or

iter/examples/simple/simple ; exit; Segmentation fault: 11 logout Saving session... ...copying shared history... ...saving history...truncating history files... ...completed.

Change to library 4.0.8.x, it works very good.

c-smile commented 6 years ago

Try this version please: http://cloud.sciter.com/index.php/s/cD78zoWAimp2ZSs Just replace yor sciter-osx-64.dylib by the one from the archive.

b1gcat commented 6 years ago

Try this version please: http://cloud.sciter.com/index.php/s/cD78zoWAimp2ZSs Just replace yor sciter-osx-64.dylib by the one from the archive.

it works fine.

c-smile commented 6 years ago

Thanks.

davetbo commented 4 years ago

Hello.

I'm getting this issue as well, and this thread is almost 2 years old. I'm on: Mac 10.12.6, GCC Version: Davids-MacBook-Pro:settings davetbo$ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 9.0.0 (clang-900.0.39.2) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

go version go1.13.6 darwin/amd64

I can't do w.LoadFile("settings.html") with either the full path to the settings.html file or ./settings.html or just settings.html (and that HTML file is in the same dir as the settings.go file).

I also tried building it and putting the html file in the go/bin folder and still got a dump.

Actually I just noticed that with settings.html copied into my go/bin directory it gets a different error. It gets this instead: 2020-01-27 19:40:13.229 trayapp[84297:2177988] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.93/Misc.subproj/NSUndoManager.m:363 2020-01-27 19:40:13.230 trayapp[84297:2177988] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.' *** First throw call stack: ( 0 CoreFoundation 0x00007fff8c2fc7eb __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00007fffa113d48d objc_exception_throw + 48 2 CoreFoundation 0x00007fff8c301562 +[NSException raise:format:arguments:] + 98 3 Foundation 0x00007fff8dd4c340 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 Foundation 0x00007fff8dcd67f3 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 170 5 AppKit 0x00007fff89d5b49d -[NSApplication run] + 1200 6 trayapp 0x0000000004278e02 _cgo_313d37c8e920_Cfunc_Run + 98 7 trayapp 0x000000000405b030 runtime.asmcgocall + 112 ) libc++abi.dylib: terminating with uncaught exception of type NSException SIGABRT: abort PC=0x7fffa1ba5d42 m=3 sigcode=0

Any thoughts?

c-smile commented 4 years ago

You definitely shall use full path of your document. To be precise not a path but absolute file url:

w.LoadFile("file://..../settings.html");

Sciter needs absolute url to properly calculate relative URL used in document.