Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6ba0c9f7098c286c802c9bda8e34db3d8f504311
      
https://github.com/WebKit/WebKit/commit/6ba0c9f7098c286c802c9bda8e34db3d8f504311
  Author: Adrian Taylor <[email protected]>
  Date:   2026-09-16 (Wed, 16 Sep 2026)

  Changed paths:
    M Source/WTF/wtf/EscapableByteSpan.h
    M Source/WebGPU/WebGPU/Buffer.h
    M Source/WebGPU/WebGPU/Buffer.mm
    M Source/WebGPU/WebGPU/Buffer.swift
    M Source/WebGPU/WebGPU/CxxBridgingPublic.h
    M Source/WebGPU/WebGPU/Queue.h
    M Source/WebGPU/WebGPU/Queue.mm
    M Source/WebGPU/WebGPU/Queue.swift
    M Source/WebGPU/WebGPU/StdLibExtras.swift
    M Tools/TestWebKitAPI/Tests/WTF/EscapableByteSpan.cpp

  Log Message:
  -----------
  [WebGPU Swift] Experimentally remove unsafe statements
https://bugs.webkit.org/show_bug.cgi?id=320989
rdar://148983910

Reviewed by Mike Wyrzykowski.

It is WebKit policy to have purely safe Swift wherever possible.
This change removes most of the remaining 'unsafe' keywords from the
Swift in WebGPU, mostly by adding further byte-span-borrowing primitives.

The steps taken are as follows:
- Within Queue.swift, we previously passed a C++ std::span from C++,
  through Swift, and back to C++. Although Swift did not access the data,
  this is deemed to be unsafe by Swift since Swift might have stashed
  the span beyond the acceptable lifetime. In this change, we use a new
  WTF::MutableByteSpan instead. This is a non-escapable wrapper for
  a std::span<uint8_t> and is more versatile than the Span<UInt8>
  which is provided by Swift's own SafeInteropWrappers.
- Queue also requires a new overload of newTemporaryBufferWithBytes
  which deals in types that Swift handles safely and idiomatically,
  instead of things like std::pair. It returns a new non-escapable
  wrapper for an id<MTLBuffer>
- In Buffer.swift, previously the getMappedRange and bufferCopyFrom
  methods acted upon a Buffer. They now instead act upon a C++
  wrapper called BufferBorrow.

We retain a single `unsafe` to make up for the lack of operator==
support from Swift.

Canonical link: https://commits.webkit.org/321250@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to