LorezV Posted July 15, 2023 Share Posted July 15, 2023 Hello everyone, I am integrating Ultralight into my project. When creating a texture, I specify the dimensions 500 x 500 and everything works fine, but if I specify a larger size, for example by the size of the main window (1600x900), then I get the following error: Unhandled exception at 0x00007FF9873AC387 (vcruntime140.dll ) in Ykon_x64d.exe : 0xC0000005: Access violation when reading at 0x000001D3D3F14000. Code for creating a texture: view = renderer->CreateView(500, 500, true, session, false); //this->view->LoadHTML("<body style='background:red;'><style>.super:hover { background: green; } </style><div class='super'>Hello from C++</div></body>"); view->LoadURL("https://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0"); view->Focus(); blob = Blob::create(); texture = Texture::create(); texture->create2D(700, 700, Texture::FORMAT_RGBA8, Texture::SAMPLER_FLAGS); Code for texture update: UL::RefPtr<UL::Bitmap> bitmap = surface->bitmap(); bitmap->SwapRedBlueChannels(); auto pixels = static_cast<unsigned char*>(bitmap->LockPixels()); uint32_t width = bitmap->width(); uint32_t height = bitmap->height(); uint32_t stride = bitmap->row_bytes(); blob->setData(pixels, stride); texture->setBlob(blob); blob->setData(nullptr, 0); sprite->setRender(texture); Link to comment
silent Posted July 18, 2023 Share Posted July 18, 2023 LorezV Could you please provide a minimal sample that we can build and test on our side? That would surely help us to find the root cause much faster. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
LorezV Posted July 18, 2023 Author Share Posted July 18, 2023 (edited) @silent I uploaded an archive called Ykon to your ftp server, it contains a full project on the 2.17 version of the engine. I implemented the logic in the ChromiumLogic class Edited July 18, 2023 by LorezV Link to comment
silent Posted July 19, 2023 Share Posted July 19, 2023 Thanks, will check it and report back when I will have more information from the dev team. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
cash-metall Posted July 19, 2023 Share Posted July 19, 2023 Hello! great job on chromium integration! the crash occurred due to a mismatch between the number of mipmaps in the texture and in the data. try to set texture flag without samplers texture = Texture::create(); //texture->create2D(700, 700, Texture::FORMAT_RGBA8, Texture::SAMPLER_FLAGS); texture->create2D(700, 700, Texture::FORMAT_RGBA8, Texture::SAMPLER_FILTER_LINEAR | Texture::FORMAT_USAGE_RENDER); Link to comment
LorezV Posted July 19, 2023 Author Share Posted July 19, 2023 (edited) @cash-metall, @silen Thank you so much for your help. I immediately had another question, I created a resize callback and execute the following code in it. But sometimes, the texture lies down with artifacts, maybe this is also corrected by flags? This happens when the window size does not look like the standard ratios(like 4:3 16:9 etc...) int ChromiumLogic::resize_callback() { Math::ivec2 size = WindowManager::getMainWindow()->getSize(); sprite->setWidth(size.x); sprite->setHeight(size.y); for (auto view : *views) { view->Resize(size.x, size.y); } texture->clearBuffer(); texture->clear(); texture->create2D(size.x, size.y, Texture::FORMAT_RGBA8, Texture::FORMAT_USAGE_RENDER | Texture::SAMPLER_FILTER_LINEAR); return 1; } Edited July 19, 2023 by LorezV 1 Link to comment
cash-metall Posted July 19, 2023 Share Posted July 19, 2023 this effect is related to UL::Bitmap align policy. bitmap->row_bytes() return not equal width * 4 (RGBA) size, but increase width to 4pixels per row (align to 16 bytes). when copying data to a texture, we do not have the ability to skip empty pixels - in textures, all data goes tightly without spaces. you can try to change size of rendered page Math::ivec2 size = WindowManager::getMainWindow()->getSize(); size.x = Math::makeAligned(size.x, 4); texture->create2D(size.x, size.y, Texture::FORMAT_RGBA8, Texture::SAMPLER_FILTER_LINEAR | Texture::FORMAT_USAGE_RENDER); sprite->setWidth(size.x); sprite->setHeight(size.y); Link to comment
LorezV Posted July 19, 2023 Author Share Posted July 19, 2023 @cash-metall It works! Thanks. Link to comment
Recommended Posts