Attempt to fix crash in story preloading.
This commit is contained in:
parent
35f0f87f73
commit
30334b6c74
|
@ -54,6 +54,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kDefaultCoverThumbnailSize = 100;
|
constexpr auto kDefaultCoverThumbnailSize = 100;
|
||||||
|
constexpr auto kMaxAllowedPreloadPrefix = 6 * 1024 * 1024;
|
||||||
|
|
||||||
const auto kLottieStickerDimensions = QSize(
|
const auto kLottieStickerDimensions = QSize(
|
||||||
kStickerSideSize,
|
kStickerSideSize,
|
||||||
|
@ -393,7 +394,7 @@ void DocumentData::setattributes(
|
||||||
if (data.is_round_message()) {
|
if (data.is_round_message()) {
|
||||||
_additional = std::make_unique<RoundData>();
|
_additional = std::make_unique<RoundData>();
|
||||||
} else if (const auto size = data.vpreload_prefix_size()) {
|
} else if (const auto size = data.vpreload_prefix_size()) {
|
||||||
if (size->v > 0) {
|
if (size->v > 0 && size->v < kMaxAllowedPreloadPrefix) {
|
||||||
_videoPreloadPrefix = size->v;
|
_videoPreloadPrefix = size->v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ public:
|
||||||
void registerPolling(not_null<Story*> story, Polling polling);
|
void registerPolling(not_null<Story*> story, Polling polling);
|
||||||
void unregisterPolling(not_null<Story*> story, Polling polling);
|
void unregisterPolling(not_null<Story*> story, Polling polling);
|
||||||
|
|
||||||
bool registerPolling(FullStoryId id, Polling polling);
|
[[nodiscard]] bool registerPolling(FullStoryId id, Polling polling);
|
||||||
void unregisterPolling(FullStoryId id, Polling polling);
|
void unregisterPolling(FullStoryId id, Polling polling);
|
||||||
void requestUserStories(
|
void requestUserStories(
|
||||||
not_null<UserData*> user,
|
not_null<UserData*> user,
|
||||||
|
|
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "media/streaming/media_streaming_reader.h"
|
#include "media/streaming/media_streaming_reader.h"
|
||||||
#include "storage/download_manager_mtproto.h"
|
#include "storage/download_manager_mtproto.h"
|
||||||
|
#include "storage/file_download.h" // kMaxFileInMemory
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
@ -574,6 +575,7 @@ void StoryPreload::load() {
|
||||||
}
|
}
|
||||||
_task = std::make_unique<LoadTask>(id(), video, [=](QByteArray data) {
|
_task = std::make_unique<LoadTask>(id(), video, [=](QByteArray data) {
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
|
Assert(data.size() < Storage::kMaxFileInMemory);
|
||||||
_story->owner().cacheBigFile().putIfEmpty(
|
_story->owner().cacheBigFile().putIfEmpty(
|
||||||
key,
|
key,
|
||||||
Storage::Cache::Database::TaggedValue(std::move(data), 0));
|
Storage::Cache::Database::TaggedValue(std::move(data), 0));
|
||||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lottie/lottie_frame_generator.h"
|
#include "lottie/lottie_frame_generator.h"
|
||||||
#include "ffmpeg/ffmpeg_frame_generator.h"
|
#include "ffmpeg/ffmpeg_frame_generator.h"
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
|
#include "storage/file_download.h" // kMaxFileInMemory
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "ui/text/text_custom_emoji.h"
|
#include "ui/text/text_custom_emoji.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
@ -345,7 +346,7 @@ void CustomEmojiLoader::check() {
|
||||||
};
|
};
|
||||||
auto put = [=, key = cacheKey(document)](QByteArray value) {
|
auto put = [=, key = cacheKey(document)](QByteArray value) {
|
||||||
const auto size = value.size();
|
const auto size = value.size();
|
||||||
if (size <= Storage::Cache::Database::Settings().maxDataSize) {
|
if (size <= Storage::kMaxFileInMemory) {
|
||||||
document->owner().cacheBigFile().put(key, std::move(value));
|
document->owner().cacheBigFile().put(key, std::move(value));
|
||||||
} else {
|
} else {
|
||||||
LOG(("Data Error: Cached emoji size too big: %1.").arg(size));
|
LOG(("Data Error: Cached emoji size too big: %1.").arg(size));
|
||||||
|
|
|
@ -283,9 +283,10 @@ BaseLayout *Provider::getLayout(
|
||||||
if (auto layout = createLayout(id, delegate)) {
|
if (auto layout = createLayout(id, delegate)) {
|
||||||
layout->initDimensions();
|
layout->initDimensions();
|
||||||
it = _layouts.emplace(id, std::move(layout)).first;
|
it = _layouts.emplace(id, std::move(layout)).first;
|
||||||
_peer->owner().stories().registerPolling(
|
const auto ok = _peer->owner().stories().registerPolling(
|
||||||
{ _peer->id, id },
|
{ _peer->id, id },
|
||||||
Data::Stories::Polling::Chat);
|
Data::Stories::Polling::Chat);
|
||||||
|
Assert(ok);
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue