Compare commits

...

14 Commits

Author SHA1 Message Date
Zed Bot
def69220f7 Bump to 0.134.2 for @ConradIrwin 2024-05-07 19:18:25 -07:00
gcp-cherry-pick-bot[bot]
041ac56892 Fix race condition in editor show_hover (cherry-pick #11441) (#11444)
Cherry-picked Fix race condition in editor show_hover (#11441)

The DisplayPoint returned from the position map is only valid at the
snapshot in the position map.

Before this change we were erroneously using it to index into the
current version of the buffer.

Release Notes:

- Fixed a panic caused by a race condition in hover.

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-05-07 20:16:43 -06:00
gcp-cherry-pick-bot[bot]
9834934a57 don't report hangs on stable (cherry-pick #11494) (#11497)
Cherry-picked don't report hangs on stable (#11494)

Release Notes:

- N/A

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-05-07 09:49:36 -06:00
gcp-cherry-pick-bot[bot]
19bf699657 Compile and instantiate wasm modules on a background thread (cherry-pick #11270) (#11287)
Cherry-picked Compile and instantiate wasm modules on a background
thread (#11270)

Release Notes:

- Fixed a hang that could occur when loading some extensions, by loading
extensions on a background thread.

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-05-01 21:48:35 -06:00
gcp-cherry-pick-bot[bot]
bc0dd3aecb Don't iterate over all system processes (cherry-pick #11281) (#11285)
Cherry-picked Don't iterate over all system processes (#11281)

Release Notes:

- Fixed a UI beachball when gathering process information

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-05-01 20:21:54 -06:00
Conrad Irwin
bb394bd9d0 Fix bundle script moar 2024-05-01 20:21:31 -06:00
Conrad Irwin
a5eec9c25e Upload file better? 2024-05-01 18:55:26 -06:00
gcp-cherry-pick-bot[bot]
9529e367a9 Only keep one blame up-to-date (cherry-pick #11274) (#11277)
Cherry-picked Only keep one blame up-to-date (#11274)

I was experiencing hang, and we blamed it on spawning a few hundred git
processes
simultaneously.

cc @MrNugget

Release Notes:

- Fixed slowness with hundreds of buffers open doing git blame.

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-05-01 18:51:05 -06:00
gcp-cherry-pick-bot[bot]
932555abca Use HIGH priority to wake blocked timers (cherry-pick #11269) (#11278)
Cherry-picked Use HIGH priority to wake blocked timers (#11269)

One contributor to some beach-balls was that the main thread was calling
block_with_timeout, but the timeout never fired.

Release Notes:

- Reduced main thread hangs under very high system load

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-05-01 18:50:52 -06:00
Conrad Irwin
6e5e482854 Fix linux bundle again maybe 2024-05-01 11:29:30 -06:00
Conrad Irwin
f3a82e450f zed 0.134.1 2024-05-01 10:44:13 -06:00
Conrad Irwin
8a1e4512c4 blerg (#11254)
Release Notes:

- N/A
2024-05-01 10:23:12 -06:00
Conrad Irwin
03abd7df78 Revert tyop (#11253)
Follup up from
https://github.com/zed-industries/zed/pull/11229#pullrequestreview-2033556336

Release Notes:

- N/A
2024-05-01 10:23:12 -06:00
Joseph T. Lyons
28b0378fe9 v0.134.x preview 2024-05-01 11:32:45 -04:00
16 changed files with 117 additions and 61 deletions

View File

@@ -329,7 +329,7 @@ jobs:
with:
draft: true
prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
files: target/release/zed-linux-x86_64.tar.gz
files: zed-linux-x86_64.tar.gz
body: ""
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
Cargo.lock generated
View File

@@ -12654,7 +12654,7 @@ dependencies = [
[[package]]
name = "zed"
version = "0.134.0"
version = "0.134.2"
dependencies = [
"activity_indicator",
"anyhow",

View File

@@ -12,7 +12,7 @@ use settings::{Settings, SettingsStore};
use sha2::{Digest, Sha256};
use std::io::Write;
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System};
use sysinfo::{CpuRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System};
use telemetry_events::{
ActionEvent, AppEvent, AssistantEvent, AssistantKind, CallEvent, CopilotEvent, CpuEvent,
EditEvent, EditorEvent, Event, EventRequestBody, EventWrapper, ExtensionEvent, MemoryEvent,
@@ -171,40 +171,38 @@ impl Telemetry {
drop(state);
let this = self.clone();
cx.spawn(|_| async move {
// Avoiding calling `System::new_all()`, as there have been crashes related to it
let refresh_kind = RefreshKind::new()
.with_memory(MemoryRefreshKind::everything()) // For memory usage
.with_processes(ProcessRefreshKind::everything()) // For process usage
.with_cpu(CpuRefreshKind::everything()); // For core count
let mut system = System::new_with_specifics(refresh_kind);
// Avoiding calling `refresh_all()`, just update what we need
system.refresh_specifics(refresh_kind);
// Waiting some amount of time before the first query is important to get a reasonable value
// https://docs.rs/sysinfo/0.29.10/sysinfo/trait.ProcessExt.html#tymethod.cpu_usage
const DURATION_BETWEEN_SYSTEM_EVENTS: Duration = Duration::from_secs(4 * 60);
loop {
smol::Timer::after(DURATION_BETWEEN_SYSTEM_EVENTS).await;
system.refresh_specifics(refresh_kind);
cx.background_executor()
.spawn(async move {
let mut system = System::new_with_specifics(
RefreshKind::new().with_cpu(CpuRefreshKind::everything()),
);
let refresh_kind = ProcessRefreshKind::new().with_cpu().with_memory();
let current_process = Pid::from_u32(std::process::id());
let Some(process) = system.processes().get(&current_process) else {
let process = current_process;
log::error!("Failed to find own process {process:?} in system process table");
// TODO: Fire an error telemetry event
return;
};
system.refresh_process_specifics(current_process, refresh_kind);
this.report_memory_event(process.memory(), process.virtual_memory());
this.report_cpu_event(process.cpu_usage(), system.cpus().len() as u32);
}
})
.detach();
// Waiting some amount of time before the first query is important to get a reasonable value
// https://docs.rs/sysinfo/0.29.10/sysinfo/trait.ProcessExt.html#tymethod.cpu_usage
const DURATION_BETWEEN_SYSTEM_EVENTS: Duration = Duration::from_secs(4 * 60);
loop {
smol::Timer::after(DURATION_BETWEEN_SYSTEM_EVENTS).await;
let current_process = Pid::from_u32(std::process::id());
system.refresh_process_specifics(current_process, refresh_kind);
let Some(process) = system.process(current_process) else {
log::error!(
"Failed to find own process {current_process:?} in system process table"
);
// TODO: Fire an error telemetry event
return;
};
this.report_memory_event(process.memory(), process.virtual_memory());
this.report_cpu_event(process.cpu_usage(), system.cpus().len() as u32);
}
})
.detach();
}
pub fn set_authenticated_user_info(

View File

@@ -264,7 +264,7 @@ pub async fn post_hang(
Error::Internal(anyhow!(err))
})?;
let mut backtrace = "Possible hang detected on main threadL".to_string();
let mut backtrace = "Possible hang detected on main thread:".to_string();
let unknown = "<unknown>".to_string();
for frame in report.backtrace.iter() {
backtrace.push_str(&format!("\n{}", frame.symbols.first().unwrap_or(&unknown)));

View File

@@ -9054,8 +9054,11 @@ impl Editor {
return;
}
let focused = self.focus_handle(cx).contains_focused(cx);
let project = project.clone();
let blame = cx.new_model(|cx| GitBlame::new(buffer, project, user_triggered, cx));
let blame =
cx.new_model(|cx| GitBlame::new(buffer, project, user_triggered, focused, cx));
self.blame_subscription = Some(cx.observe(&blame, |_, _, cx| cx.notify()));
self.blame = Some(blame);
}
@@ -10055,6 +10058,10 @@ impl Editor {
let rename_editor_focus_handle = rename.editor.read(cx).focus_handle.clone();
cx.focus(&rename_editor_focus_handle);
} else {
if let Some(blame) = self.blame.as_ref() {
blame.update(cx, GitBlame::focus)
}
self.blink_manager.update(cx, BlinkManager::enable);
self.show_cursor_names(cx);
self.buffer.update(cx, |buffer, cx| {
@@ -10075,6 +10082,10 @@ impl Editor {
self.blink_manager.update(cx, BlinkManager::disable);
self.buffer
.update(cx, |buffer, cx| buffer.remove_active_selections(cx));
if let Some(blame) = self.blame.as_ref() {
blame.update(cx, GitBlame::blur)
}
self.hide_context_menu(cx);
hide_hover(self, cx);
cx.emit(EditorEvent::Blurred);

View File

@@ -629,7 +629,7 @@ impl EditorElement {
editor.update_hovered_link(point_for_position, &position_map.snapshot, modifiers, cx);
if let Some(point) = point_for_position.as_valid() {
hover_at(editor, Some(point), cx);
hover_at(editor, Some((point, &position_map.snapshot)), cx);
Self::update_visible_cursor(editor, point, position_map, cx);
} else {
hover_at(editor, None, cx);

View File

@@ -88,7 +88,9 @@ pub struct GitBlame {
buffer_snapshot: BufferSnapshot,
buffer_edits: text::Subscription,
task: Task<Result<()>>,
focused: bool,
generated: bool,
changed_while_blurred: bool,
user_triggered: bool,
regenerate_on_edit_task: Task<Result<()>>,
_regenerate_subscriptions: Vec<Subscription>,
@@ -99,6 +101,7 @@ impl GitBlame {
buffer: Model<Buffer>,
project: Model<Project>,
user_triggered: bool,
focused: bool,
cx: &mut ModelContext<Self>,
) -> Self {
let entries = SumTree::from_item(
@@ -153,6 +156,8 @@ impl GitBlame {
entries,
buffer_edits,
user_triggered,
focused,
changed_while_blurred: false,
commit_details: HashMap::default(),
task: Task::ready(Ok(())),
generated: false,
@@ -186,6 +191,18 @@ impl GitBlame {
})
}
pub fn blur(&mut self, _: &mut ModelContext<Self>) {
self.focused = false;
}
pub fn focus(&mut self, cx: &mut ModelContext<Self>) {
self.focused = true;
if self.changed_while_blurred {
self.changed_while_blurred = false;
self.generate(cx);
}
}
fn sync(&mut self, cx: &mut ModelContext<Self>) {
let edits = self.buffer_edits.consume();
let new_snapshot = self.buffer.read(cx).snapshot();
@@ -298,6 +315,10 @@ impl GitBlame {
}
fn generate(&mut self, cx: &mut ModelContext<Self>) {
if !self.focused {
self.changed_while_blurred = true;
return;
}
let buffer_edits = self.buffer.update(cx, |buffer, _| buffer.subscribe());
let snapshot = self.buffer.read(cx).snapshot();
let blame = self.project.read(cx).blame_buffer(&self.buffer, None, cx);
@@ -544,7 +565,8 @@ mod tests {
.await
.unwrap();
let blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project.clone(), true, cx));
let blame =
cx.new_model(|cx| GitBlame::new(buffer.clone(), project.clone(), true, true, cx));
let event = project.next_event(cx).await;
assert_eq!(
@@ -613,7 +635,7 @@ mod tests {
.await
.unwrap();
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, cx));
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
cx.executor().run_until_parked();
@@ -693,7 +715,7 @@ mod tests {
.await
.unwrap();
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, cx));
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
cx.executor().run_until_parked();
@@ -842,7 +864,7 @@ mod tests {
.await
.unwrap();
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, cx));
let git_blame = cx.new_model(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
cx.executor().run_until_parked();
git_blame.update(cx, |blame, cx| blame.check_invariants(cx));

View File

@@ -31,15 +31,20 @@ pub const HOVER_POPOVER_GAP: Pixels = px(10.);
/// Bindable action which uses the most recent selection head to trigger a hover
pub fn hover(editor: &mut Editor, _: &Hover, cx: &mut ViewContext<Editor>) {
let head = editor.selections.newest_display(cx).head();
show_hover(editor, head, true, cx);
let snapshot = editor.snapshot(cx);
show_hover(editor, head, &snapshot, true, cx);
}
/// The internal hover action dispatches between `show_hover` or `hide_hover`
/// depending on whether a point to hover over is provided.
pub fn hover_at(editor: &mut Editor, point: Option<DisplayPoint>, cx: &mut ViewContext<Editor>) {
pub fn hover_at(
editor: &mut Editor,
point: Option<(DisplayPoint, &EditorSnapshot)>,
cx: &mut ViewContext<Editor>,
) {
if EditorSettings::get_global(cx).hover_popover_enabled {
if let Some(point) = point {
show_hover(editor, point, false, cx);
if let Some((point, snapshot)) = point {
show_hover(editor, point, snapshot, false, cx);
} else {
hide_hover(editor, cx);
}
@@ -160,6 +165,7 @@ pub fn hide_hover(editor: &mut Editor, cx: &mut ViewContext<Editor>) -> bool {
fn show_hover(
editor: &mut Editor,
point: DisplayPoint,
snapshot: &EditorSnapshot,
ignore_timeout: bool,
cx: &mut ViewContext<Editor>,
) {
@@ -167,7 +173,6 @@ fn show_hover(
return;
}
let snapshot = editor.snapshot(cx);
let multibuffer_offset = point.to_offset(&snapshot.display_snapshot, Bias::Left);
let (buffer, buffer_position) = if let Some(output) = editor
@@ -234,6 +239,7 @@ fn show_hover(
return;
}
}
let snapshot = snapshot.clone();
let task = cx.spawn(|this, mut cx| {
async move {
@@ -659,7 +665,10 @@ mod tests {
fn test() { printˇln!(); }
"});
cx.update_editor(|editor, cx| hover_at(editor, Some(hover_point), cx));
cx.update_editor(|editor, cx| {
let snapshot = editor.snapshot(cx);
hover_at(editor, Some((hover_point, &snapshot)), cx)
});
assert!(!cx.editor(|editor, _| editor.hover_state.visible()));
// After delay, hover should be visible.
@@ -705,7 +714,10 @@ mod tests {
let mut request = cx
.lsp
.handle_request::<lsp::request::HoverRequest, _, _>(|_, _| async move { Ok(None) });
cx.update_editor(|editor, cx| hover_at(editor, Some(hover_point), cx));
cx.update_editor(|editor, cx| {
let snapshot = editor.snapshot(cx);
hover_at(editor, Some((hover_point, &snapshot)), cx)
});
cx.background_executor
.advance_clock(Duration::from_millis(HOVER_DELAY_MILLIS + 100));
request.next().await;

View File

@@ -106,9 +106,9 @@ impl WasmHost {
wasm_bytes: Vec<u8>,
manifest: Arc<ExtensionManifest>,
executor: BackgroundExecutor,
) -> impl 'static + Future<Output = Result<WasmExtension>> {
) -> Task<Result<WasmExtension>> {
let this = self.clone();
async move {
executor.clone().spawn(async move {
let zed_api_version = parse_wasm_extension_version(&manifest.id, &wasm_bytes)?;
let component = Component::from_binary(&this.engine, &wasm_bytes)
@@ -147,7 +147,7 @@ impl WasmHost {
tx,
zed_api_version,
})
}
})
}
async fn build_wasi_ctx(&self, manifest: &Arc<ExtensionManifest>) -> Result<wasi::WasiCtx> {

View File

@@ -47,7 +47,6 @@ mod macos {
.header("src/platform/mac/dispatch.h")
.allowlist_var("_dispatch_main_q")
.allowlist_var("_dispatch_source_type_data_add")
.allowlist_var("DISPATCH_QUEUE_PRIORITY_DEFAULT")
.allowlist_var("DISPATCH_QUEUE_PRIORITY_HIGH")
.allowlist_var("DISPATCH_TIME_NOW")
.allowlist_function("dispatch_get_global_queue")

View File

@@ -76,7 +76,7 @@ impl PlatformDispatcher for MacDispatcher {
fn dispatch_after(&self, duration: Duration, runnable: Runnable) {
unsafe {
let queue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT.try_into().unwrap(), 0);
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH.try_into().unwrap(), 0);
let when = dispatch_time(DISPATCH_TIME_NOW as u64, duration.as_nanos() as i64);
dispatch_after_f(
when,

View File

@@ -98,8 +98,14 @@ impl PtyProcessInfo {
fn refresh(&mut self) -> Option<&Process> {
let pid = self.pid_getter.pid()?;
self.system.refresh_processes_specifics(self.refresh_kind);
self.system.process(pid)
if self
.system
.refresh_process_specifics(pid, self.refresh_kind)
{
self.system.process(pid)
} else {
None
}
}
fn load(&mut self) -> Option<ProcessInfo> {

View File

@@ -2,7 +2,7 @@
description = "The fast, collaborative code editor."
edition = "2021"
name = "zed"
version = "0.134.0"
version = "0.134.2"
publish = false
license = "GPL-3.0-or-later"
authors = ["Zed Team <hi@zed.dev>"]

View File

@@ -1 +1 @@
dev
preview

View File

@@ -183,6 +183,14 @@ pub fn monitor_main_thread_hangs(
installation_id: Option<String>,
cx: &AppContext,
) {
// This is too noisy to ship to stable for now.
if !matches!(
ReleaseChannel::global(cx),
ReleaseChannel::Dev | ReleaseChannel::Nightly | ReleaseChannel::Preview
) {
return;
}
use nix::sys::signal::{
sigaction, SaFlags, SigAction, SigHandler, SigSet,
Signal::{self, SIGUSR2},

View File

@@ -52,17 +52,17 @@ zed_dir="${temp_dir}/zed$suffix.app"
# Binary
mkdir -p "${zed_dir}/bin"
cp "target/${target_triple}/release/Zed" "${zed_dir}/zed"
cp "target/${target_triple}/release/Zed" "${zed_dir}/bin/zed"
# Icons
mkdir -p "${zed_dir}/share/icons/hicolor/512x512/apps"
cp "crates/zed/resources/app-icon$suffix.png" "${zed_dir}/share/icons/hicolor/512x512/apps/zed.png"
mkdir -p "${zed_dir}/share/icons/hicolor/1024x1024/apps"
cp "crates/zed/resources/app-icon$suffix/share/icons/hicolor/1024x1024/apps/zed.png"
cp "crates/zed/resources/app-icon$suffix@2x.png" "${zed_dir}/share/icons/hicolor/1024x1024/apps/zed.png"
# .desktop
mkdir -p "${zed_dir}/share/applications"
cp "crates/zed/resources/zed$suffix.desktop" "${zed_dir}/share/applications/zed$suffix.desktop"
cp "crates/zed/resources/zed.desktop" "${zed_dir}/share/applications/zed$suffix.desktop"
if [[ "$channel" == "preview" ]]; then
sed -i "s|Name=Zed|Name=Zed Preview|g" "${zed_dir}/share/applications/zed$suffix.desktop"
elif [[ "$channel" == "nightly" ]]; then
@@ -84,4 +84,4 @@ else
fi
rm -rf "${archive}"
tar -czvf $archive -C ${temp_dir} ${zed_dir}
tar -czvf $archive -C ${temp_dir} "zed$suffix.app"