fix(wallets): probe synchronously during the offline screenshot sweep
The async probe fills badges/counts a frame after the dialog opens, which the single-frame screenshot sweep captured before it landed (badges/counts missing). Run the probe synchronously when App::isScreenshotSweeping(), so the captured modal-wallets frame is populated; interactive use keeps the detached-thread path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -502,33 +502,40 @@ private:
|
|||||||
targets.reserve(s_rows.size());
|
targets.reserve(s_rows.size());
|
||||||
for (std::size_t i = 0; i < s_rows.size(); ++i)
|
for (std::size_t i = 0; i < s_rows.size(); ++i)
|
||||||
targets.emplace_back(s_rows[i].dir + "/" + s_rows[i].fileName, i);
|
targets.emplace_back(s_rows[i].dir + "/" + s_rows[i].fileName, i);
|
||||||
if (!targets.empty()) {
|
|
||||||
std::thread([batch, targets]() {
|
auto runProbe = [](std::shared_ptr<ProbeBatch> batch,
|
||||||
// Per-file 256 MB (BDB sorts long-keyed mkey/hdchain LATE, so a small cap risks a
|
std::vector<std::pair<std::string, std::size_t>> targets) {
|
||||||
// false-negative); a shared budget bounds total I/O, charged by bytes actually read.
|
// Per-file 256 MB (BDB sorts long-keyed mkey/hdchain LATE, so a small cap risks a
|
||||||
std::size_t budget = 768u * 1024u * 1024u;
|
// false-negative); a shared budget bounds total I/O, charged by bytes actually read.
|
||||||
constexpr std::size_t kPerFile = 256u * 1024u * 1024u;
|
std::size_t budget = 768u * 1024u * 1024u;
|
||||||
for (const auto& t : targets) {
|
constexpr std::size_t kPerFile = 256u * 1024u * 1024u;
|
||||||
if (batch->cancel.load()) return;
|
for (const auto& t : targets) {
|
||||||
ProbeResult res;
|
if (batch->cancel.load()) return;
|
||||||
if (budget > 0) {
|
ProbeResult res;
|
||||||
// Primary: an exact btree walk (encryption/seed flags + address/tx counts). If it
|
if (budget > 0) {
|
||||||
// can't fully parse (unknown BDB variant, or a >cap file), fall back to the cheap
|
// Primary: an exact btree walk (encryption/seed flags + address/tx counts). If it
|
||||||
// byte-scan for badges only (no counts).
|
// can't fully parse (unknown BDB variant, or a >cap file), fall back to the cheap
|
||||||
const auto bt = util::parseWalletBtree(t.first, std::min(budget, kPerFile));
|
// byte-scan for badges only (no counts).
|
||||||
if (bt.parsed && bt.complete) {
|
const auto bt = util::parseWalletBtree(t.first, std::min(budget, kPerFile));
|
||||||
res = ProbeResult{ true, true, bt.encrypted, bt.hdSeed, true, bt.addresses(), bt.txCount };
|
if (bt.parsed && bt.complete) {
|
||||||
budget -= std::min(budget, bt.bytesRead);
|
res = ProbeResult{ true, true, bt.encrypted, bt.hdSeed, true, bt.addresses(), bt.txCount };
|
||||||
} else {
|
budget -= std::min(budget, bt.bytesRead);
|
||||||
const auto pr = util::probeWalletFile(t.first, std::min(budget, kPerFile));
|
} else {
|
||||||
res = ProbeResult{ pr.isBerkeleyDB, pr.scanComplete, pr.encrypted, pr.hdSeed };
|
const auto pr = util::probeWalletFile(t.first, std::min(budget, kPerFile));
|
||||||
budget -= std::min(budget, std::max(bt.bytesRead, pr.bytesRead));
|
res = ProbeResult{ pr.isBerkeleyDB, pr.scanComplete, pr.encrypted, pr.hdSeed };
|
||||||
}
|
budget -= std::min(budget, std::max(bt.bytesRead, pr.bytesRead));
|
||||||
}
|
}
|
||||||
std::lock_guard<std::mutex> lk(batch->mtx);
|
|
||||||
if (t.second < batch->results.size()) batch->results[t.second] = res;
|
|
||||||
}
|
}
|
||||||
}).detach();
|
std::lock_guard<std::mutex> lk(batch->mtx);
|
||||||
|
if (t.second < batch->results.size()) batch->results[t.second] = res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (targets.empty()) {
|
||||||
|
// nothing to probe
|
||||||
|
} else if (s_app && s_app->isScreenshotSweeping()) {
|
||||||
|
runProbe(batch, targets); // offline sweep: probe synchronously so the captured frame is populated
|
||||||
|
} else {
|
||||||
|
std::thread(runProbe, batch, targets).detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user