helloadhavan/github_issues huggingface dataset:
Repository: vercel/next.js
Pull request: Turbopack: delete .next folder before throwing due to "pages/app directory must be in the same folder"

### What?

I expect an empty .next folder after an error, so it should delete it before doing the check, so that an error doesn't result in a stale .next folder

Closes PACK-5644

Changed files:
filename: packages/next/src/build/index.ts
patch: @@ -1016,6 +1016,34 @@ export default async function build(
       NextBuildContext.originalRewrites = config._originalRewrites
       NextBuildContext.originalRedirects = config._originalRedirects
 
+      const distDirCreated = await nextBuildSpan
+        .traceChild('create-dist-dir')
+        .traceAsyncFn(async () => {
+          try {
+            await fs.mkdir(distDir, { recursive: true })
+            return true
+          } catch (err) {
+            if (isError(err) && err.code === 'EPERM') {
+              return false
+            }
+            throw err
+          }
+        })
+
+      if (!distDirCreated || !(await isWriteable(distDir))) {
+        throw new Error(
+          '> Build directory is not writeable. https://nextjs.org/docs/messages/build-dir-not-writeable'
+        )
+      }
+
+      if (config.cleanDistDir && !isGenerateMode) {
+        await nextBuildSpan
+          .traceChild('clean')
+          .traceAsyncFn(() =>
+            recursiveDeleteSyncWithAsyncRetries(distDir, /^(cache|dev)/)
+          )
+      }
+
       const cacheDir = getCacheDir(distDir)
 
       const telemetry = new Telemetry({ distDir })
@@ -1102,34 +1130,6 @@ export default async function build(
         cacheDir,
       }
 
-      const distDirCreated = await nextBuildSpan
-        .traceChild('create-dist-dir')
-        .traceAsyncFn(async () => {
-          try {
-            await fs.mkdir(distDir, { recursive: true })
-            return true
-          } catch (err) {
-            if (isError(err) && err.code === 'EPERM') {
-              return false
-            }
-            throw err
-          }
-        })
-
-      if (!distDirCreated || !(await isWriteable(distDir))) {
-        throw new Error(
-          '> Build directory is not writeable. https://nextjs.org/docs/messages/build-dir-not-writeable'
-        )
-      }
-
-      if (config.cleanDistDir && !isGenerateMode) {
-        await nextBuildSpan
-          .traceChild('clean')
-          .traceAsyncFn(() =>
-            recursiveDeleteSyncWithAsyncRetries(distDir, /^(cache|dev)/)
-          )
-      }
-
       if (appDir && 'exportPathMap' in config) {
         Log.error(
           'The "exportPathMap" configuration cannot be used with the "app" directory. Please use generateStaticParams() instead.'

filename: packages/next/src/lib/recursive-delete.ts
patch: @@ -74,7 +74,7 @@ export async function recursiveDeleteSyncWithAsyncRetries(
   dir: string,
   /** Exclude based on relative file path */
   exclude?: RegExp,
-  /** Ensures that parameter dir exists, this is not passed recursively */
+  /** Relative path to the directory being deleted, used for exclude */
   previousPath: string = ''
 ): Promise<void> {
   let result
Repository: electron/electron
Pull request: fix: Reland "[accessibility] Platform node lifetime cleanups"

#### Description of Change

Copy upstream change from https://chromium-review.googlesource.com/c/chromium/src/+/6462552 to our copy of `
RecursiveDumpAXPlatformNodeAsString()` in `shell/browser/ui/webui/accessibility_ui.cc`.

#### Checklist

- [x] PR description included and stakeholders cc'd
- [x] `npm test` passes
- [x] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: none.

Changed files:
filename: shell/browser/ui/webui/accessibility_ui.cc
patch: @@ -306,7 +306,8 @@ std::string RecursiveDumpAXPlatformNodeAsString(
     return "";
   }
   std::string str(2 * indent, '+');
-  std::string line = node->GetDelegate()->GetData().ToString();
+  ui::AXPlatformNodeDelegate* const node_delegate = node->GetDelegate();
+  std::string line = node_delegate->GetData().ToString();
   std::vector<std::string> attributes = base::SplitString(
       line, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
   for (const std::string& attribute : attributes) {
@@ -316,8 +317,9 @@ std::string RecursiveDumpAXPlatformNodeAsString(
     }
   }
   str += "\n";
-  for (size_t i = 0; i < node->GetDelegate()->GetChildCount(); i++) {
-    gfx::NativeViewAccessible child = node->GetDelegate()->ChildAtIndex(i);
+  for (size_t i = 0, child_count = node_delegate->GetChildCount();
+       i < child_count; i++) {
+    gfx::NativeViewAccessible child = node_delegate->ChildAtIndex(i);
     ui::AXPlatformNode* child_node =
         ui::AXPlatformNode::FromNativeViewAccessible(child);
     str += RecursiveDumpAXPlatformNodeAsString(child_node, indent + 1,
Repository: nodejs/node
Pull request: stream: replace manual function validation with validateFunction

stream: replace manual function validation with validateFunction

Replace repetitive manual function type checking with the existing
validateFunction in multiple stream operator functions.


Changed files:
filename: lib/internal/streams/operators.js
patch: @@ -18,7 +18,6 @@ const { AbortController, AbortSignal } = require('internal/abort_controller');
 const {
   AbortError,
   codes: {
-    ERR_INVALID_ARG_TYPE,
     ERR_INVALID_ARG_VALUE,
     ERR_MISSING_ARGS,
     ERR_OUT_OF_RANGE,
@@ -28,6 +27,7 @@ const {
   validateAbortSignal,
   validateInteger,
   validateObject,
+  validateFunction,
 } = require('internal/validators');
 const { kWeakHandler, kResistStopPropagation } = require('internal/event_target');
 const { finished } = require('internal/streams/end-of-stream');
@@ -66,10 +66,7 @@ function compose(stream, options) {
 }
 
 function map(fn, options) {
-  if (typeof fn !== 'function') {
-    throw new ERR_INVALID_ARG_TYPE(
-      'fn', ['Function', 'AsyncFunction'], fn);
-  }
+  validateFunction(fn, 'fn');
   if (options != null) {
     validateObject(options, 'options');
   }
@@ -223,10 +220,7 @@ async function some(fn, options = undefined) {
 }
 
 async function every(fn, options = undefined) {
-  if (typeof fn !== 'function') {
-    throw new ERR_INVALID_ARG_TYPE(
-      'fn', ['Function', 'AsyncFunction'], fn);
-  }
+  validateFunction(fn, 'fn');
   // https://en.wikipedia.org/wiki/De_Morgan%27s_laws
   return !(await some.call(this, async (...args) => {
     return !(await fn(...args));
@@ -241,10 +235,7 @@ async function find(fn, options) {
 }
 
 async function forEach(fn, options) {
-  if (typeof fn !== 'function') {
-    throw new ERR_INVALID_ARG_TYPE(
-      'fn', ['Function', 'AsyncFunction'], fn);
-  }
+  validateFunction(fn, 'fn');
   async function forEachFn(value, options) {
     await fn(value, options);
     return kEmpty;
@@ -254,10 +245,7 @@ async function forEach(fn, options) {
 }
 
 function filter(fn, options) {
-  if (typeof fn !== 'function') {
-    throw new ERR_INVALID_ARG_TYPE(
-      'fn', ['Function', 'AsyncFunction'], fn);
-  }
+  validateFunction(fn, 'fn');
   async function filterFn(value, options) {
     if (await fn(value, options)) {
       return value;
@@ -277,10 +265,7 @@ class ReduceAwareErrMissingArgs extends ERR_MISSING_ARGS {
 }
 
 async function reduce(reducer, initialValue, options) {
-  if (typeof reducer !== 'function') {
-    throw new ERR_INVALID_ARG_TYPE(
-      'reducer', ['Function', 'AsyncFunction'], reducer);
-  }
+  validateFunction(reducer, 'reducer');
   if (options != null) {
     validateObject(options, 'options');
   }
Repository: ollama/ollama
Pull request: fixes for gguf

This change:
  * adds the KVs for moes
  * catches when an improper type was used in the KVs (we can add more if/when this changes)
  * accounts for n-tensors in 8x22b moe models (where n > 2)

Changed files:
filename: llm/gguf.go
patch: @@ -190,8 +190,6 @@ func (llm *gguf) Decode(rs io.ReadSeeker) error {
 		llm.kv[k] = v
 	}
 
-	slog.Debug(fmt.Sprintf("general.architecture = %s", llm.kv["general.architecture"]))
-
 	// decode tensors
 	for i := 0; uint64(i) < llm.numTensor(); i++ {
 		name, err := readGGUFString(llm, rs)
@@ -465,11 +463,13 @@ var ggufKVOrder = map[string][]string{
 		"llama.embedding_length",
 		"llama.block_count",
 		"llama.feed_forward_length",
-		"llama.rope.dimension_count",
 		"llama.attention.head_count",
 		"llama.attention.head_count_kv",
 		"llama.attention.layer_norm_rms_epsilon",
 		"llama.rope.freq_base",
+		"llama.rope.dimension_count",
+		"llama.expert_count",
+		"llama.expert_used_count",
 		"gemma.context_length",
 		"gemma.embedding_length",
 		"gemma.block_count",
@@ -577,6 +577,8 @@ func (llm *gguf) Encode(ws io.WriteSeeker, kv KV, tensors []Tensor) error {
 					return err
 				}
 			}
+		default:
+			return fmt.Errorf("improper type for '%s'", k)
 		}
 		if err != nil {
 			return err
@@ -598,9 +600,11 @@ func (llm *gguf) Encode(ws io.WriteSeeker, kv KV, tensors []Tensor) error {
 			return err
 		}
 
-		dims := 1
-		if tensor.Shape[1] > 0 {
-			dims = 2
+		dims := 0
+		for cnt := 0; cnt < len(tensor.Shape); cnt++ {
+			if tensor.Shape[cnt] > 0 {
+				dims++
+			}
 		}
 
 		if err := binary.Write(ws, llm.ByteOrder, uint32(dims)); err != nil {
Repository: huggingface/transformers
Pull request: [QoL] modular conversion shows LoC saved

# What does this PR do?

Tiny thing. Simply print the LoC saved when doing modular conversion.

<img width="1528" height="81" alt="image" src="https://github.com/user-attachments/assets/a6bab118-5dc9-4550-991e-eb8acaa657f4" />

## Why?

Because we sometimes hesitate too much (me first). Modular isn't magic, it's close,and it can't do everything. I sometimes want to optimize too much a conversion that's already leagues better than if I was using `modeling` directly. 

Changed files:
filename: utils/modular_model_converter.py
patch: @@ -1743,12 +1743,39 @@ def save_modeling_files(modular_file: str, converted_files: dict[str, str]):
             f.write(converted_files[file_type])
 
 
+def count_loc(file_path: str) -> int:
+    with open(file_path, "r", encoding="utf-8") as f:
+        code = f.read()
+    comment_less_code = re.sub(r"#.*", "", code).strip()
+    comment_less_code = re.sub(r" *\n", "\n", comment_less_code).strip()
+    return len([line for line in comment_less_code.split("\n") if line.strip()])
+
+
 def run_converter(modular_file: str):
     """Convert a modular file, and save resulting files."""
     print(f"Converting {modular_file} to a single model single file format")
     converted_files = convert_modular_file(modular_file)
     save_modeling_files(modular_file, converted_files)
 
+    model_directory = os.path.dirname(modular_file)
+    modular_loc = count_loc(modular_file)
+
+    autogenerated_files = []
+    for file in os.listdir(model_directory):
+        if file.endswith(".py") and not file.startswith("modular_"):
+            file_path = os.path.join(model_directory, file)
+            with open(file_path, "r", encoding="utf-8") as f:
+                if "This file was automatically generated from" in f.read():
+                    autogenerated_files.append(file_path)
+
+    if autogenerated_files:
+        total_generated_loc = sum(count_loc(f) for f in autogenerated_files)
+        savings = total_generated_loc - modular_loc
+        percentage = (savings / total_generated_loc) * 100
+        print(
+            f"LoC: {modular_loc} (modular) vs {total_generated_loc} (generated) - saved {savings} LoC ({percentage:.1f}%)"
+        )
+
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser()
Repository: ggml-org/llama.cpp
Pull request: added note for old Intel hardware pre sycl

Older hardware used opencl


Changed files:
filename: docs/backend/SYCL.md
patch: @@ -103,6 +103,8 @@ SYCL backend supports Intel GPU Family:
 - Intel Built-in Arc GPU
 - Intel iGPU in Core CPU (11th Generation Core CPU and newer, refer to [oneAPI supported GPU](https://www.intel.com/content/www/us/en/developer/articles/system-requirements/intel-oneapi-base-toolkit-system-requirements.html#inpage-nav-1-1)).
 
+On older Intel GPUs, you may try [OpenCL](/docs/backend/OPENCL.md) although the performance is not optimal, and some GPUs may not support OpenCL nor have any GPGPU capabilities.
+
 #### Verified devices
 
 | Intel GPU                     | Status  | Verified Model                        |
Repository: electron/electron
Pull request: perf: avoid copying a vector when calling ConvertToWeakPtrVector()

Backport of #47593

See that PR for details.


Notes: none.

Changed files:
filename: shell/browser/window_list.cc
patch: @@ -6,20 +6,18 @@
 
 #include <algorithm>
 
+#include "base/containers/to_vector.h"
 #include "base/no_destructor.h"
 #include "shell/browser/native_window.h"
 #include "shell/browser/window_list_observer.h"
 
 namespace {
+
 template <typename T>
-std::vector<base::WeakPtr<T>> ConvertToWeakPtrVector(std::vector<T*> raw_ptrs) {
-  std::vector<base::WeakPtr<T>> converted_to_weak;
-  converted_to_weak.reserve(raw_ptrs.size());
-  for (auto* raw_ptr : raw_ptrs) {
-    converted_to_weak.push_back(raw_ptr->GetWeakPtr());
-  }
-  return converted_to_weak;
+auto ConvertToWeakPtrVector(const std::vector<T*>& raw_ptrs) {
+  return base::ToVector(raw_ptrs, [](T* t) { return t->GetWeakPtr(); });
 }
+
 }  // namespace
 
 namespace electron {
Repository: ollama/ollama
Pull request: Add back memory escape valve

If we get our predictions wrong, this can be used to set a lower memory limit as a workaround.  Recent multi-gpu refactoring accidentally removed it, so this adds it back.

Changed files:
filename: llm/memory.go
patch: @@ -3,6 +3,8 @@ package llm
 import (
 	"fmt"
 	"log/slog"
+	"os"
+	"strconv"
 	"strings"
 
 	"github.com/ollama/ollama/api"
@@ -49,6 +51,17 @@ func EstimateGPULayers(gpus []gpu.GpuInfo, ggml *GGML, projectors []string, opts
 	for _, info := range gpus {
 		memoryAvailable += info.FreeMemory
 	}
+	userLimit := os.Getenv("OLLAMA_MAX_VRAM")
+	if userLimit != "" {
+		avail, err := strconv.ParseUint(userLimit, 10, 64)
+		if err != nil {
+			slog.Error("invalid setting, ignoring", "OLLAMA_MAX_VRAM", userLimit, "error", err)
+		} else {
+			slog.Info("user override memory limit", "OLLAMA_MAX_VRAM", avail, "actual", memoryAvailable)
+			memoryAvailable = avail
+		}
+	}
+
 	slog.Debug("evaluating", "library", gpus[0].Library, "gpu_count", len(gpus), "available", format.HumanBytes2(memoryAvailable))
 
 	// TODO - this is probably wrong, first GPU vs secondaries will have different overheads
Repository: facebook/react
Pull request: [compiler][be] Remove completed todo comment

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom):
* __->__ #30633
* #30632

We made block types explicit a long time ago, this comment is super stale

Changed files:
filename: compiler/packages/babel-plugin-react-compiler/src/HIR/MergeConsecutiveBlocks.ts
patch: @@ -25,8 +25,6 @@ import {terminalFallthrough, terminalHasFallthrough} from './visitors';
  * Note that this pass leaves value/loop blocks alone because they cannot
  * be merged without breaking the structure of the high-level terminals
  * that reference them.
- *
- * TODO @josephsavona make value blocks explicit (eg a `kind` on Block).
  */
 export function mergeConsecutiveBlocks(fn: HIRFunction): void {
   const merged = new MergedBlocks();
Repository: huggingface/transformers
Pull request: [Parakeet] unnecessary warning & auto mapping

# What does this PR do?

- fixes #41387
- and fixes warning 
```
🚨 Config not found for parakeet. You can manually add it to HARDCODED_CONFIG_FOR_MODELS in utils/auto_docstring.py
```
- and fixes auto tokenizer mapping that was not updated when moving from `ParakeetCTCTokenizer` to `ParakeetTokenizerFast`
---
What triggers the unexpected warning:

`@auto_doctring` on a class (not on a method) (here `ParakeetPreTrainedModel`, `ParakeetEncoder`, `ParakeetForCTC`) triggers `auto_method_docstring`  call **with parent_class kwargs setted**, that will trigger looking for a config class with the model name `parakeet` (extracted from `modeling_parakeet.py`). Yet we don't have a config class for `parakeet` alone, we have `ParakeetEncoderConfig` and `ParakeetCTCConfig`.

To solve, let's add `"parakeet": "ParakeetCTCConfig"` to `HARDCODED_CONFIG_FOR_MODELS`.

>[!NOTE]
> When other Parakeet variants will be integrated `ParakeetForTDT` and `ParakeetForRNTT`, then we might want to add a global ParakeetConfig that encapsulate them all


Changed files:
filename: src/transformers/models/auto/tokenization_auto.py
patch: @@ -509,7 +509,7 @@
         ("owlv2", ("CLIPTokenizer", "CLIPTokenizerFast" if is_tokenizers_available() else None)),
         ("owlvit", ("CLIPTokenizer", "CLIPTokenizerFast" if is_tokenizers_available() else None)),
         ("paligemma", ("LlamaTokenizer", "LlamaTokenizerFast" if is_tokenizers_available() else None)),
-        ("parakeet", ("ParakeetCTCTokenizer", None)),
+        ("parakeet", (None, "ParakeetTokenizerFast" if is_tokenizers_available() else None)),
         (
             "pegasus",
             (

filename: src/transformers/utils/auto_docstring.py
patch: @@ -66,6 +66,7 @@
     "kosmos2-5": "Kosmos2_5Config",
     "donut": "DonutSwinConfig",
     "esmfold": "EsmConfig",
+    "parakeet": "ParakeetCTCConfig",
 }
 
 _re_checkpoint = re.compile(r"\[(.+?)\]\((https://huggingface\.co/.+?)\)")
Repository: ggml-org/llama.cpp
Pull request: security : add collaborator guidance

See https://github.com/ggml-org/llama.cpp/discussions/18080

Changed files:
filename: SECURITY.md
patch: @@ -68,3 +68,6 @@ Please disclose it as a private [security advisory](https://github.com/ggml-org/
 Please note that using AI to identify vulnerabilities and generate reports is permitted. However, you must (1) explicitly disclose how AI was used and (2) conduct a thorough manual review before submitting the report.
 
 A team of volunteers on a reasonable-effort basis maintains this project. As such, please give us at least 90 days to work on a fix before public exposure.
+
+> [!IMPORTANT]
+> For collaborators: if you are interested in helping out with reviewing privting security disclosures, please see: https://github.com/ggml-org/llama.cpp/discussions/18080
Repository: electron/electron
Pull request: perf: avoid copying a vector when calling ConvertToWeakPtrVector()

#### Description of Change

Have `ConvertToWeakPtrVector()` take a `const vector&` instead of a `vector` to avoid an unnecessary vector copy.

#### Checklist

- [x] PR description included and stakeholders cc'd
- [x] `npm test` passes
- [x] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: none.

Changed files:
filename: shell/browser/window_list.cc
patch: @@ -6,20 +6,18 @@
 
 #include <algorithm>
 
+#include "base/containers/to_vector.h"
 #include "base/no_destructor.h"
 #include "shell/browser/native_window.h"
 #include "shell/browser/window_list_observer.h"
 
 namespace {
+
 template <typename T>
-std::vector<base::WeakPtr<T>> ConvertToWeakPtrVector(std::vector<T*> raw_ptrs) {
-  std::vector<base::WeakPtr<T>> converted_to_weak;
-  converted_to_weak.reserve(raw_ptrs.size());
-  for (auto* raw_ptr : raw_ptrs) {
-    converted_to_weak.push_back(raw_ptr->GetWeakPtr());
-  }
-  return converted_to_weak;
+auto ConvertToWeakPtrVector(const std::vector<T*>& raw_ptrs) {
+  return base::ToVector(raw_ptrs, [](T* t) { return t->GetWeakPtr(); });
 }
+
 }  // namespace
 
 namespace electron {
Repository: ollama/ollama
Pull request: Detect and recover if runner removed

Tmp cleaners can nuke the file out from underneath us.  This detects the missing runner, and re-initializes the payloads.

Manually tested by hand removing the server after loading it once, trigger an unload with `keep_alive: 0` sent another request, saw the log message, and it loaded correctly.

Changed files:
filename: .github/workflows/test.yaml
patch: @@ -260,7 +260,7 @@ jobs:
         shell: bash
       - uses: golangci/golangci-lint-action@v4
         with:
-          args: --timeout 8m0s
+          args: --timeout 8m0s -v
   test:
     strategy:
       matrix:

filename: llm/server.go
patch: @@ -250,6 +250,17 @@ func NewLlamaServer(gpus gpu.GpuInfoList, model string, ggml *GGML, adapters, pr
 			server = server + ".exe"
 		}
 
+		// Detect tmp cleaners wiping out the file
+		_, err := os.Stat(server)
+		if errors.Is(err, os.ErrNotExist) {
+			slog.Warn("llama server disappeared, reinitializing payloads", "path", server, "error", err)
+			err = Init()
+			if err != nil {
+				slog.Warn("failed to reinitialize payloads", "error", err)
+				return nil, err
+			}
+		}
+
 		s := &llmServer{
 			port:          port,
 			cmd:           exec.Command(server, finalParams...),
Repository: vercel/next.js
Pull request: Turbopack: Lower the IO concurrency limit in CI tests

@lukesandberg pointed out that we have test flakes from too many file descriptors open.

I think we should significantly raise these limits on the ci runners (@ijjk?), but given that we run 8 tests in parallel, it's probably good anyways for Turbopack to be less aggressive with file IO in our CI.

Closes PACK-5635

Changed files:
filename: .github/workflows/build_reusable.yml
patch: @@ -110,6 +110,9 @@ env:
   NEXT_CI_RUNNER: ${{ inputs.runs_on_labels }}
   NEXT_TEST_PROXY_ADDRESS: ${{ inputs.overrideProxyAddress || '' }}
 
+  # defaults to 256, but we run a lot of tests in parallel, so the limit should be lower
+  NEXT_TURBOPACK_IO_CONCURRENCY: 64
+
 jobs:
   build:
     timeout-minutes: ${{ inputs.timeout_minutes }}

filename: turbopack/crates/turbo-tasks-fs/src/lib.rs
patch: @@ -31,6 +31,7 @@ mod watcher;
 use std::{
     borrow::Cow,
     cmp::{Ordering, min},
+    env,
     fmt::{self, Debug, Display, Formatter},
     fs::FileType,
     future::Future,
@@ -193,7 +194,20 @@ where
 }
 
 fn create_semaphore() -> tokio::sync::Semaphore {
-    tokio::sync::Semaphore::new(256)
+    // the semaphore isn't serialized, and we assume the environment variable doesn't change during
+    // runtime, so it's okay to access it in this untracked way.
+    static NEXT_TURBOPACK_IO_CONCURRENCY: LazyLock<usize> = LazyLock::new(|| {
+        env::var("NEXT_TURBOPACK_IO_CONCURRENCY")
+            .ok()
+            .filter(|val| !val.is_empty())
+            .map(|val| {
+                val.parse()
+                    .expect("NEXT_TURBOPACK_IO_CONCURRENCY must be a valid integer")
+            })
+            .filter(|val| *val != 0)
+            .unwrap_or(256)
+    });
+    tokio::sync::Semaphore::new(*NEXT_TURBOPACK_IO_CONCURRENCY)
 }
 
 #[turbo_tasks::value_trait]
Repository: electron/electron
Pull request: fix: Reland "[accessibility] Platform node lifetime cleanups"

Backport of #47590

See that PR for details.


Notes: none.

Changed files:
filename: shell/browser/ui/webui/accessibility_ui.cc
patch: @@ -307,7 +307,8 @@ std::string RecursiveDumpAXPlatformNodeAsString(
     return "";
   }
   std::string str(2 * indent, '+');
-  std::string line = node->GetDelegate()->GetData().ToString();
+  ui::AXPlatformNodeDelegate* const node_delegate = node->GetDelegate();
+  std::string line = node_delegate->GetData().ToString();
   std::vector<std::string> attributes = base::SplitString(
       line, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
   for (const std::string& attribute : attributes) {
@@ -317,8 +318,9 @@ std::string RecursiveDumpAXPlatformNodeAsString(
     }
   }
   str += "\n";
-  for (size_t i = 0; i < node->GetDelegate()->GetChildCount(); i++) {
-    gfx::NativeViewAccessible child = node->GetDelegate()->ChildAtIndex(i);
+  for (size_t i = 0, child_count = node_delegate->GetChildCount();
+       i < child_count; i++) {
+    gfx::NativeViewAccessible child = node_delegate->ChildAtIndex(i);
     ui::AXPlatformNode* child_node =
         ui::AXPlatformNode::FromNativeViewAccessible(child);
     str += RecursiveDumpAXPlatformNodeAsString(child_node, indent + 1,