Crash in Windows for SkParagraph

163 views
Skip to first unread message

Hemanth

unread,
Aug 29, 2024, 8:40:31 AM8/29/24
to skia-discuss

Hello,

Previously I tried with skia m113 version. But that issue is not resolved due to "SK_UNICODE_CLIENT_IMPLEMENTATION" flag. If I set it in my properties or in my c++/winrt application it is not enabled. If I set it in ParagraphBuilderImpl.h it is giving linker error.

Based on previous meeting I switched to skia m128 version. At first FontMgr and TypeFace are null. Then I used  

sk_sp<SkFontMgr> fontMgr = SkFontMgr_New_DirectWrite();

sk_sp<SkTypeface> typeFace = fontMgr->legacyMakeTypeface("Marlett", fontStyle);

Now I was able to create fontMgr and typeFace properly.

But while doing ParagraphBuilder->Build() fUnicode is not creating.

std::unique_ptr<Paragraph> para = builder->Build();

Above image is paragraphBuilderImpl.cpp code

And Output is

client not defined

Empty

Flag should be defined to create fUnicode or else it is having Null value.

I tried to include "SK_UNICODE_CLIENT_IMPLEMENTATION" flag in my properties and C++/winrt app
but it still says flag is not defined

When I included it in paragraphBuilderImpl.h  file it is giving Linker error

#define SK_UNICODE_CLIENT_IMPLEMENTATION 1

Severity Code Description Project File Line Suppression State Details

Error LNK2001 unresolved external symbol "class sk_sp<class SkUnicode> __cdecl SkUnicodes::Client::Make(class SkSpan<char>,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> >,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> >,class std::vector<struct SkUnicode::LineBreakBefore,class std::allocator<struct SkUnicode::LineBreakBefore> >)" (?Make@Client@SkUnicodes@@YA?AV?$sk_sp@VSkUnicode@@@@V?$SkSpan@D@@V?$vector@_KV?$allocator@_K@std@@@std@@1V?$vector@ULineBreakBefore@SkUnicode@@V?$allocator@ULineBreakBefore@SkUnicode@@@std@@@6@@Z) SwapchainCpp C:\Users\Administrator\Desktop\SwapchainCpp\skparagraph.lib(skparagraph.ParagraphBuilderImpl.obj)

Is there a proper way to define the flag and create fUnicode?

Thank you

Hemanth

unread,
Aug 29, 2024, 8:44:16 AM8/29/24
to skia-discuss

Above image is paragraphBuilderImpl.cpp code


error image

Hemanth

unread,
Aug 29, 2024, 8:49:04 AM8/29/24
to skia-discuss
Sorry unable to send the photo properly

paragraphBuilderImpl.cpp code

std::unique_ptr<Paragraph> ParagraphBuilderImpl::Build() {
    this->finalize();
    // Add one fake placeholder with the rest of the text
    this->addPlaceholder(PlaceholderStyle(), true);
    fUTF8IndexForUTF16Index.clear();
    fUTF16IndexForUTF8Index.clear();


#ifdef SK_UNICODE_CLIENT_IMPLEMENTATION
    SkDebugf("client defined\n");
#else
    SkDebugf("client not defined\n");
#endif  // def SK_UNICODE_CLIENT_IMPLEMENTATION


#if !defined(SK_DISABLE_LEGACY_PARAGRAPH_UNICODE) && defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
    SkDebugf("In cond-1\n");
    if (fUsingClientInfo && !fUnicode) {
        SkDebugf("In cond-2\n");
        // This is the place where SkUnicode is paired with SkParagraph
        fUnicode = SkUnicodes::Client::Make(this->getText(),
                                            std::move(fWordsUtf16),
                                            std::move(fGraphemeBreaksUtf8),
                                            std::move(fLineBreaksUtf8));
    }
#endif

    //SkDebugf("In build - 2\n");
    //SkASSERT_RELEASE(fUnicode);
    if (!fUnicode)
        SkDebugf("Empty\n");
    else
        SkDebugf("Not empty\n");
    return std::make_unique<ParagraphImpl>(
            fUtf8, fParagraphStyle, fStyledBlocks, fPlaceholders, fFontCollection, fUnicode);
}

Output:
client not defined
Empty

Hemanth

unread,
Aug 30, 2024, 8:04:08 AM8/30/24
to skia-discuss
SkUnicode_icu.cpp file

ss9.png

if I comment #if condition completely from line 488 to 496 then Text is rendering properly using SkParagraph

I'm unable find out why SkLoadICU() is returning false value here

Can someone explain what is the use of SkLoadICU() and why we are checking it?

 

Thank you.

Hemanth

unread,
Sep 2, 2024, 3:43:25 AM9/2/24
to skia-discuss
Hello,

Text is drawing using SkParagraph now.
The main reason for that crash was because it is trying to find icudt.dat file in bin/x64/Debug/Appx path but it was not present there.
MakeIcuBasedUnicode() function in SkUnicode_icu.cpp it is calling SkLoadICU() function(SkLoadICU.cpp) in that it's expecting icudt.dat file either in executable_directory or in library_directory.
I included dat file in that path and it is working fine now.

Is it a proper way to fix the issue or is there any better way to do it?

Thanks for your help.

jlav...@google.com

unread,
Sep 3, 2024, 11:13:07 AM9/3/24
to skia-discuss
It's all in your build procedure. 
You need to understand how you build Skia, how you link Skia and what files you provide to it on run time.
Without knowing all these details we cannot help you much.

aisnote com

unread,
Sep 17, 2024, 5:29:54 PM9/17/24
to skia-d...@googlegroups.com
skia_use_system_icu=false
try to set true on the building

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/49bd3032-7cca-4c79-a3ae-75c718f8572cn%40googlegroups.com.

aisnote com

unread,
Sep 17, 2024, 5:29:58 PM9/17/24
to skia-d...@googlegroups.com
Did you put this file into the same folder of your application, if you use: skia_use_system_icu=false
icudtl.dat

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.

Hemanth

unread,
Sep 18, 2024, 10:31:29 AM9/18/24
to skia-d...@googlegroups.com
Hello,

Thank you for your email
Issue got resolved
It was expecting icudtl.dat file in executable_directory()

Hemanth Y


Reply all
Reply to author
Forward
0 new messages