helloadhavan/github_issues huggingface dataset:
Repository: ollama/ollama
Pull request: remove unused openssh key types


Changed files:
filename: format/openssh.go
patch: @@ -10,15 +10,11 @@ package format
 
 import (
 	"crypto"
-	"crypto/ecdsa"
 	"crypto/ed25519"
-	"crypto/elliptic"
 	"crypto/rand"
-	"crypto/rsa"
 	"encoding/binary"
 	"encoding/pem"
 	"fmt"
-	"math/big"
 
 	"golang.org/x/crypto/ssh"
 )
@@ -41,25 +37,6 @@ type openSSHPrivateKey struct {
 	Rest    []byte `ssh:"rest"`
 }
 
-type openSSHRSAPrivateKey struct {
-	N       *big.Int
-	E       *big.Int
-	D       *big.Int
-	Iqmp    *big.Int
-	P       *big.Int
-	Q       *big.Int
-	Comment string
-	Pad     []byte `ssh:"rest"`
-}
-
-type openSSHECDSAPrivateKey struct {
-	Curve   string
-	Pub     []byte
-	D       *big.Int
-	Comment string
-	Pad     []byte `ssh:"rest"`
-}
-
 type openSSHEd25519PrivateKey struct {
 	Pub     []byte
 	Priv    []byte
@@ -85,64 +62,6 @@ func OpenSSHPrivateKey(key crypto.PrivateKey, comment string) (*pem.Block, error
 	}
 
 	switch k := key.(type) {
-	case *rsa.PrivateKey:
-		e := new(big.Int).SetInt64(int64(k.E))
-
-		key := openSSHRSAPrivateKey{
-			N:       k.N,
-			E:       e,
-			D:       k.D,
-			Iqmp:    k.Precomputed.Qinv,
-			P:       k.Primes[0],
-			Q:       k.Primes[1],
-			Comment: comment,
-		}
-
-		pk1.Keytype = ssh.KeyAlgoRSA
-		pk1.Rest = ssh.Marshal(key)
-
-		w.PubKey = ssh.Marshal(struct {
-			KeyType string
-			E       *big.Int
-			N       *big.Int
-		}{
-			ssh.KeyAlgoRSA, e, k.N,
-		})
-	case *ecdsa.PrivateKey:
-		var curve, keytype string
-		switch name := k.Curve.Params().Name; name {
-		case "P-256":
-			curve = "nistp256"
-			keytype = ssh.KeyAlgoECDSA256
-		case "P-384":
-			curve = "nistp384"
-			keytype = ssh.KeyAlgoECDSA384
-		case "P-521":
-			curve = "nistp521"
-			keytype = ssh.KeyAlgoECDSA521
-		default:
-			return nil, fmt.Errorf("ssh: unknown curve %q", name)
-		}
-
-		pub := elliptic.Marshal(k.Curve, k.X, k.Y)
-
-		key := openSSHECDSAPrivateKey{
-			Curve:   curve,
-			Pub:     pub,
-			D:       k.D,
-			Comment: comment,
-		}
-
-		pk1.Keytype = keytype
-		pk1.Rest = ssh.Marshal(key)
-
-		w.PubKey = ssh.Marshal(struct {
-			KeyType string
-			Curve   string
-			Pub     []byte
-		}{
-			keytype, curve, pub,
-		})
 	case ed25519.PrivateKey:
 		pub, priv := k[32:], k
 		key := openSSHEd25519PrivateKey{
Repository: ggml-org/llama.cpp
Pull request: Fix missing messages on sibling navigation

Close #16406

Resolves issue with messages disappearing when navigating between regenerated siblings by using current leaf nodes instead of cached sibling IDs.

Changed files:
filename: tools/server/webui/src/lib/stores/chat.svelte.ts
patch: @@ -860,15 +860,18 @@ class ChatStore {
 			this.currentResponse = '';
 
 			try {
-				const assistantMessage = await this.createAssistantMessage();
+				const parentMessageId =
+					this.activeMessages.length > 0
+						? this.activeMessages[this.activeMessages.length - 1].id
+						: null;
+
+				const assistantMessage = await this.createAssistantMessage(parentMessageId);
 
 				if (!assistantMessage) {
 					throw new Error('Failed to create assistant message');
 				}
 
 				this.activeMessages.push(assistantMessage);
-				await DatabaseStore.updateCurrentNode(this.activeConversation.id, assistantMessage.id);
-				this.activeConversation.currNode = assistantMessage.id;
 
 				const conversationContext = this.activeMessages.slice(0, -1);
 
@@ -1124,8 +1127,10 @@ class ChatStore {
 			(m) => m.role === 'user' && m.parent === rootMessage?.id
 		);
 
-		await DatabaseStore.updateCurrentNode(this.activeConversation.id, siblingId);
-		this.activeConversation.currNode = siblingId;
+		const currentLeafNodeId = findLeafNode(allMessages, siblingId);
+
+		await DatabaseStore.updateCurrentNode(this.activeConversation.id, currentLeafNodeId);
+		this.activeConversation.currNode = currentLeafNodeId;
 		await this.refreshActiveMessages();
 
 		// Only show title dialog if we're navigating between different first user message siblings
Repository: ollama/ollama
Pull request: fix model manifests

follow up to #473 which only created the parent directory, not manifests itself

Changed files:
filename: server/modelpath.go
patch: @@ -115,7 +115,7 @@ func GetManifestPath() (string, error) {
 	}
 
 	path := filepath.Join(home, ".ollama", "models", "manifests")
-	if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
+	if err := os.MkdirAll(path, 0o755); err != nil {
 		return "", err
 	}
Repository: facebook/react
Pull request: Make enableBigIntSupport a dynamic flag for Meta

Make enableBigIntSupport a dynamic flag for Meta

Should be an easy launch, but let's make this a dynamic flag to be safe.


Changed files:
filename: packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js
patch: @@ -21,6 +21,7 @@ export const alwaysThrottleDisappearingFallbacks = __VARIANT__;
 export const alwaysThrottleRetries = __VARIANT__;
 export const consoleManagedByDevToolsDuringStrictMode = __VARIANT__;
 export const enableAsyncActions = __VARIANT__;
+export const enableBigIntSupport = __VARIANT__;
 export const enableComponentStackLocations = __VARIANT__;
 export const enableDeferRootSchedulingToMicrotask = __VARIANT__;
 export const enableInfiniteRenderLoopDetection = __VARIANT__;

filename: packages/shared/forks/ReactFeatureFlags.native-fb.js
patch: @@ -23,6 +23,7 @@ export const {
   alwaysThrottleRetries,
   consoleManagedByDevToolsDuringStrictMode,
   enableAsyncActions,
+  enableBigIntSupport,
   enableComponentStackLocations,
   enableDeferRootSchedulingToMicrotask,
   enableInfiniteRenderLoopDetection,
@@ -102,7 +103,5 @@ export const disableStringRefs = false;
 export const enableReactTestRendererWarning = false;
 export const disableLegacyMode = false;
 
-export const enableBigIntSupport = false;
-
 // Flow magic to verify the exports of this file match the original version.
 ((((null: any): ExportsType): FeatureFlagsType): ExportsType);

filename: packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
patch: @@ -92,7 +92,7 @@ export const disableStringRefs = false;
 export const enableReactTestRendererWarning = false;
 export const disableLegacyMode = false;
 
-export const enableBigIntSupport = false;
+export const enableBigIntSupport = true;
 
 // Flow magic to verify the exports of this file match the original version.
 ((((null: any): ExportsType): FeatureFlagsType): ExportsType);

filename: packages/shared/forks/ReactFeatureFlags.www-dynamic.js
patch: @@ -15,6 +15,7 @@
 
 export const disableInputAttributeSyncing = __VARIANT__;
 export const disableIEWorkarounds = __VARIANT__;
+export const enableBigIntSupport = __VARIANT__;
 export const enableLegacyFBSupport = __VARIANT__;
 export const enableUseRefAccessWarning = __VARIANT__;
 export const disableSchedulerTimeoutInWorkLoop = __VARIANT__;

filename: packages/shared/forks/ReactFeatureFlags.www.js
patch: @@ -17,6 +17,7 @@ const dynamicFeatureFlags: DynamicFeatureFlags = require('ReactFeatureFlags');
 export const {
   disableInputAttributeSyncing,
   disableIEWorkarounds,
+  enableBigIntSupport,
   enableTrustedTypesIntegration,
   enableLegacyFBSupport,
   enableDebugTracing,
@@ -116,8 +117,6 @@ export const enableServerComponentLogs = true;
 
 export const enableReactTestRendererWarning = false;
 
-export const enableBigIntSupport = false;
-
 // TODO: Roll out with GK. Don't keep as dynamic flag for too long, though,
 // because JSX is an extremely hot path.
 export const disableStringRefs = false;
Repository: ollama/ollama
Pull request: tighten up the error string for `ollama show` flags


Changed files:
filename: cmd/cmd.go
patch: @@ -281,9 +281,9 @@ func ShowHandler(cmd *cobra.Command, args []string) error {
 	}
 
 	if flagsSet > 1 {
-		return errors.New("only one of 'license', 'modelfile', 'parameters', 'system', or 'template' can be set")
+		return errors.New("only one of '--license', '--modelfile', '--parameters', '--system', or '--template' can be specified")
 	} else if flagsSet == 0 {
-		return errors.New("one of 'license', 'modelfile', 'parameters', 'system', or 'template' must be set")
+		return errors.New("one of '--license', '--modelfile', '--parameters', '--system', or '--template' must be specified")
 	}
 
 	req := api.ShowRequest{Name: args[0]}
Repository: ggml-org/llama.cpp
Pull request: model: add Granite Hybrid models

add Granite 4 models mapping their embedding dimensions to the # of parameters.

Information taken from https://huggingface.co/ibm-granite/granite-4.0-h-tiny

*Make sure to read the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md) before submitting a PR*


Changed files:
filename: src/llama-model.cpp
patch: @@ -114,6 +114,7 @@ const char * llm_type_name(llm_type type) {
         case LLM_TYPE_17B_16E:       return "17Bx16E (Scout)";
         case LLM_TYPE_17B_128E:      return "17Bx128E (Maverick)";
         case LLM_TYPE_A13B:          return "A13B";
+        case LLM_TYPE_7B_A1B:        return "7B.A1B";
         case LLM_TYPE_8B_A1B:        return "8B.A1B";
         case LLM_TYPE_21B_A3B:       return "21B.A3B";
         case LLM_TYPE_30B_A3B:       return "30B.A3B";
@@ -1843,8 +1844,10 @@ void llama_model::load_hparams(llama_model_loader & ml) {
 
                 ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps);
 
-                switch (hparams.n_layer) {
-                    // TODO: Add llm type label (not sure this is useful)
+                switch (hparams.n_embd) {
+                    case 1536: type = LLM_TYPE_7B_A1B; break;
+                    case 2048: case 2560: type = LLM_TYPE_3B; break;
+                    case 4096: type = LLM_TYPE_32B; break;
                     default: type = LLM_TYPE_UNKNOWN;
                 }
 

filename: src/llama-model.h
patch: @@ -107,6 +107,7 @@ enum llm_type {
     LLM_TYPE_17B_16E, // llama4 Scout
     LLM_TYPE_17B_128E, // llama4 Maverick
     LLM_TYPE_A13B,
+    LLM_TYPE_7B_A1B,
     LLM_TYPE_8B_A1B, // lfm2moe
     LLM_TYPE_21B_A3B, // Ernie MoE small
     LLM_TYPE_30B_A3B,
Repository: denoland/deno
Pull request: fix(napi): buffer finalizer is nullable

Fixes: https://github.com/denoland/deno/issues/30512

Changed files:
filename: ext/napi/js_native_api.rs
patch: @@ -2938,7 +2938,7 @@ fn napi_create_external_arraybuffer<'s>(
   env: &'s mut Env,
   data: *mut c_void,
   byte_length: usize,
-  finalize_cb: napi_finalize,
+  finalize_cb: Option<napi_finalize>,
   finalize_hint: *mut c_void,
   result: *mut napi_value<'s>,
 ) -> napi_status {

filename: ext/napi/node_api.rs
patch: @@ -319,7 +319,7 @@ fn napi_create_external_buffer<'s>(
   env: &'s mut Env,
   length: usize,
   data: *mut c_void,
-  finalize_cb: napi_finalize,
+  finalize_cb: Option<napi_finalize>,
   finalize_hint: *mut c_void,
   result: *mut napi_value<'s>,
 ) -> napi_status {

filename: ext/napi/util.rs
patch: @@ -25,15 +25,17 @@ pub fn get_array_buffer_ptr(ab: v8::Local<v8::ArrayBuffer>) -> *mut c_void {
 
 struct BufferFinalizer {
   env: *mut Env,
-  finalize_cb: napi_finalize,
+  finalize_cb: Option<napi_finalize>,
   finalize_data: *mut c_void,
   finalize_hint: *mut c_void,
 }
 
 impl Drop for BufferFinalizer {
   fn drop(&mut self) {
-    unsafe {
-      (self.finalize_cb)(self.env as _, self.finalize_data, self.finalize_hint);
+    if let Some(finalize_cb) = self.finalize_cb {
+      unsafe {
+        finalize_cb(self.env as _, self.finalize_data, self.finalize_hint);
+      }
     }
   }
 }
@@ -56,7 +58,7 @@ pub(crate) fn make_external_backing_store(
   data: *mut c_void,
   byte_length: usize,
   finalize_data: *mut c_void,
-  finalize_cb: napi_finalize,
+  finalize_cb: Option<napi_finalize>,
   finalize_hint: *mut c_void,
 ) -> v8::UniqueRef<v8::BackingStore> {
   let finalizer = Box::new(BufferFinalizer {

filename: tests/napi/arraybuffer_test.js
patch: @@ -1,6 +1,7 @@
 // Copyright 2018-2025 the Deno authors. MIT license.
 
 import { assert, assertEquals, loadTestLibrary } from "./common.js";
+import { Buffer } from "node:buffer";
 
 const typedarray = loadTestLibrary();
 
@@ -22,3 +23,8 @@ Deno.test("napi arraybuffer is detached", function () {
     assert(!typedarray.is_detached(value));
   });
 });
+
+Deno.test("napi buffer finalizer may be null", () => {
+  const buf = typedarray.test_static_external_buffer();
+  assertEquals(buf, Buffer.from([1, 2, 3]));
+});

filename: tests/napi/src/finalizer.rs
patch: @@ -107,6 +107,24 @@ extern "C" fn test_external_buffer(
   result
 }
 
+extern "C" fn test_static_external_buffer(
+  env: napi_env,
+  _: napi_callback_info,
+) -> napi_value {
+  let mut result = ptr::null_mut();
+  static BUF: &[u8] = &[1, 2, 3];
+  assert_napi_ok!(napi_create_external_buffer(
+    env,
+    BUF.len(),
+    BUF.as_ptr() as _,
+    None,
+    ptr::null_mut(),
+    &mut result
+  ));
+
+  result
+}
+
 extern "C" fn test_external_arraybuffer(
   env: napi_env,
   _: napi_callback_info,
@@ -136,6 +154,11 @@ pub fn init(env: napi_env, exports: napi_value) {
       "test_external_arraybuffer",
       test_external_arraybuffer
     ),
+    napi_new_property!(
+      env,
+      "test_static_external_buffer",
+      test_static_external_buffer
+    ),
   ];
 
   assert_napi_ok!(napi_define_properties(
Repository: vercel/next.js
Pull request: Turbopack: Fix logic in HMR logging code that could emit a NaN build time

The goal of this module is to avoid logging no-op build events. Turbopack uses a bottom-up execution model which leads to a lot of really short no-op "building" events that we try to filter out.

If `onBuilding` isn't called before `onBuilt`, then `deferredReportHmrStartId` will be `undefined` here, causing us to report the end of a build. Since `onBuilding` wasn't called yet, the start time will be `undefined`, giving us a duration of `NaN`.

We were using `deferredReportHmrStartId` to try to determine when we'd already reported the start of a build, but it wasn't quite right. Instead, use a separate, more explicit, variable for that.

---

https://vercel.slack.com/archives/C046HAU4H7F/p1749456305992089?thread_ts=1749455727.004169&cid=C046HAU4H7F

> we fire the BUILDING event from the server, before a client is present, then the client attaches, and eventually  BUILT is sent and we trigger the NaN ms log

Thanks for the root-causing help, @icyJoseph

---

Tested by loading `pnpm next dev --turbopack examples/basic-css/` and modifying the source code to trigger HMRs.

![Screenshot 2025-08-05 at 6.09.47 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/6ee43248-af68-4478-ac9f-93ea6a3d3a51.png)

Closes PACK-5263

Changed files:
filename: packages/next/src/client/dev/hot-reloader/turbopack-hot-reloader-common.ts
patch: @@ -23,9 +23,11 @@ export class TurbopackHmr {
   #startMsSinceEpoch: number | undefined
   #lastUpdateMsSinceEpoch: number | undefined
   #deferredReportHmrStartId: ReturnType<typeof setTimeout> | undefined
+  #reportedHmrStart: boolean
 
   constructor() {
     this.#updatedModules = new Set()
+    this.#reportedHmrStart = false
   }
 
   // HACK: Turbopack tends to generate a lot of irrelevant "BUILDING" actions,
@@ -39,6 +41,7 @@ export class TurbopackHmr {
   #runDeferredReportHmrStart() {
     if (this.#deferredReportHmrStartId != null) {
       console.log('[Fast Refresh] rebuilding')
+      this.#reportedHmrStart = true
       this.#cancelDeferredReportHmrStart()
     }
   }
@@ -102,7 +105,7 @@ export class TurbopackHmr {
     // which can happen during initial page load. Ignore that too!
     const hasUpdates =
       this.#lastUpdateMsSinceEpoch != null && this.#startMsSinceEpoch != null
-    if (!hasUpdates && this.#deferredReportHmrStartId != null) {
+    if (!hasUpdates && !this.#reportedHmrStart) {
       // suppress the update entirely
       this.#cancelDeferredReportHmrStart()
       return null
@@ -116,6 +119,7 @@ export class TurbopackHmr {
       endMsSinceEpoch: this.#lastUpdateMsSinceEpoch ?? Date.now(),
     }
     this.#updatedModules = new Set()
+    this.#reportedHmrStart = false
     return result
   }
 }
Repository: ggml-org/llama.cpp
Pull request: CODEOWNERS: update for ggml-cuda/mmf


Changed files:
filename: CODEOWNERS
patch: @@ -55,7 +55,7 @@
 /ggml/src/ggml-cuda/common.cuh          @slaren
 /ggml/src/ggml-cuda/fattn*              @JohannesGaessler
 /ggml/src/ggml-cuda/ggml-cuda.cu        @slaren
-/ggml/src/ggml-cuda/mmf.*               @JohannesGaessler
+/ggml/src/ggml-cuda/mmf.*               @JohannesGaessler @am17an
 /ggml/src/ggml-cuda/mmq.*               @JohannesGaessler
 /ggml/src/ggml-cuda/mmvf.*              @JohannesGaessler
 /ggml/src/ggml-cuda/mmvq.*              @JohannesGaessler
Repository: ollama/ollama
Pull request: create manifests directory

`ollama list` on a brand new install will panic because the manifests directory doesn't exist

Changed files:
filename: server/modelpath.go
patch: @@ -114,7 +114,12 @@ func GetManifestPath() (string, error) {
 		return "", err
 	}
 
-	return filepath.Join(home, ".ollama", "models", "manifests"), nil
+	path := filepath.Join(home, ".ollama", "models", "manifests")
+	if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
+		return "", err
+	}
+
+	return path, nil
 }
 
 func GetBlobsPath(digest string) (string, error) {
Repository: nodejs/node
Pull request: doc: add Filip Skokan to TSC

Refs: https://github.com/nodejs/TSC/issues/1740

cc: @panva 

Changed files:
filename: README.md
patch: @@ -180,6 +180,8 @@ For information about the governance of the Node.js project, see
   **Matteo Collina** <<matteo.collina@gmail.com>> (he/him)
 * [mhdawson](https://github.com/mhdawson) -
   **Michael Dawson** <<midawson@redhat.com>> (he/him)
+* [panva](https://github.com/panva) -
+  **Filip Skokan** <<panva.ip@gmail.com>> (he/him)
 * [RafaelGSS](https://github.com/RafaelGSS) -
   **Rafael Gonzaga** <<rafael.nunu@hotmail.com>> (he/him)
 * [RaisinTen](https://github.com/RaisinTen) -
Repository: huggingface/transformers
Pull request: Skip broken tests

# What does this PR do?

These tests were meant to be skipped as well but they aren't run always so I missed them the last time. And not they appear on CI as flaky 🙃 


Changed files:
filename: tests/models/gemma3n/test_modeling_gemma3n.py
patch: @@ -436,6 +436,14 @@ def test_dola_decoding_sample(self):
     def test_generate_with_quant_cache(self):
         pass
 
+    @unittest.skip("Gemma3n applies key/query norm which doesn't work with packing")
+    def test_eager_padding_matches_padding_free_with_position_ids(self):
+        pass
+
+    @unittest.skip("Gemma3n applies key/query norm which doesn't work with packing")
+    def test_sdpa_padding_matches_padding_free_with_position_ids(self):
+        pass
+
 
 class Gemma3nVision2TextModelTester:
     text_config = {"activation_sparsity_pattern": None}
@@ -646,6 +654,14 @@ def test_initialization(self):
     def test_flex_attention_with_grads(self):
         pass
 
+    @unittest.skip("Gemma3n applies key/query norm which doesn't work with packing")
+    def test_eager_padding_matches_padding_free_with_position_ids(self):
+        pass
+
+    @unittest.skip("Gemma3n applies key/query norm which doesn't work with packing")
+    def test_sdpa_padding_matches_padding_free_with_position_ids(self):
+        pass
+
     def test_automodelforcausallm(self):
         """
         Regression test for #36741 -- make sure `AutoModelForCausalLM` works with a Gemma3n config, i.e. that

filename: tests/models/mllama/test_modeling_mllama.py
patch: @@ -256,6 +256,14 @@ def create_and_check_mllama_model_fp16_forward(self, config, input_ids, pixel_va
             )["logits"]
         self.parent.assertFalse(torch.isnan(logits).any().item())
 
+    @unittest.skip("Mllama applies key/query norm which doesn't work with packing")
+    def test_eager_padding_matches_padding_free_with_position_ids(self):
+        pass
+
+    @unittest.skip("Mllama applies key/query norm which doesn't work with packing")
+    def test_sdpa_padding_matches_padding_free_with_position_ids(self):
+        pass
+
 
 @require_torch
 class MllamaForConditionalGenerationModelTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase):
@@ -386,6 +394,14 @@ def test_disk_offload_bin(self):
     def test_disk_offload_safetensors(self):
         pass
 
+    @unittest.skip("Mllama applies key/query norm which doesn't work with packing")
+    def test_eager_padding_matches_padding_free_with_position_ids(self):
+        pass
+
+    @unittest.skip("Mllama applies key/query norm which doesn't work with packing")
+    def test_sdpa_padding_matches_padding_free_with_position_ids(self):
+        pass
+
     @pytest.mark.generate
     # overridden because mllama is not an encoder-decoder model, but has encoder-decoder-like cache
     def test_past_key_values_format(self):
Repository: electron/electron
Pull request: fix: leaked `gfx::Canvas` in `AutofillPopupView::OnPaint()`

Backport of #46384

See that PR for details.


Notes: Fixed memory leak in AutofillPopupView.

Changed files:
filename: shell/browser/ui/views/autofill_popup_view.cc
patch: @@ -5,6 +5,7 @@
 #include "shell/browser/ui/views/autofill_popup_view.h"
 
 #include <memory>
+#include <optional>
 #include <utility>
 
 #include "base/functional/bind.h"
@@ -237,30 +238,33 @@ void AutofillPopupView::DoUpdateBoundsAndRedrawPopup() {
 void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
   if (!popup_ || static_cast<size_t>(popup_->line_count()) != children().size())
     return;
-  gfx::Canvas* draw_canvas = canvas;
-  SkBitmap bitmap;
 
-  std::unique_ptr<cc::SkiaPaintCanvas> paint_canvas;
-  if (view_proxy_.get()) {
-    bitmap.allocN32Pixels(popup_->popup_bounds_in_view().width(),
-                          popup_->popup_bounds_in_view().height(), true);
-    paint_canvas = std::make_unique<cc::SkiaPaintCanvas>(bitmap);
-    draw_canvas = new gfx::Canvas(paint_canvas.get(), 1.0);
+  gfx::Rect offscreen_bounds;
+  SkBitmap offscreen_bitmap;
+  std::optional<cc::SkiaPaintCanvas> offscreen_paint_canvas;
+  std::optional<gfx::Canvas> offscreen_draw_canvas;
+  if (view_proxy_) {
+    offscreen_bounds = popup_->popup_bounds_in_view();
+    offscreen_bitmap.allocN32Pixels(offscreen_bounds.width(),
+                                    offscreen_bounds.height(), true);
+    offscreen_paint_canvas.emplace(offscreen_bitmap);
+    offscreen_draw_canvas.emplace(&offscreen_paint_canvas.value(), 1.0);
+    canvas = &offscreen_draw_canvas.value();
   }
 
-  draw_canvas->DrawColor(
+  canvas->DrawColor(
       GetColorProvider()->GetColor(ui::kColorResultsTableNormalBackground));
-  OnPaintBorder(draw_canvas);
+  OnPaintBorder(canvas);
 
   for (int i = 0; i < popup_->line_count(); ++i) {
     gfx::Rect line_rect = popup_->GetRowBounds(i);
 
-    DrawAutofillEntry(draw_canvas, i, line_rect);
+    DrawAutofillEntry(canvas, i, line_rect);
   }
 
-  if (view_proxy_.get()) {
-    view_proxy_->SetBounds(popup_->popup_bounds_in_view());
-    view_proxy_->SetBitmap(bitmap);
+  if (view_proxy_) {
+    view_proxy_->SetBounds(offscreen_bounds);
+    view_proxy_->SetBitmap(offscreen_bitmap);
   }
 }