Backed out 2 changesets (bug 1899874) It is crashing the browser on windows and linux, Bug 1906687. CLOSED TREE

Backed out changeset cd0e7d18bbff (bug 1899874)
Backed out changeset 347c3fe4a18f (bug 1899874)
This commit is contained in:
Cristian Tuns 2024-07-09 17:48:05 -04:00
Родитель 58f9d11924
Коммит eea96fab49
22 изменённых файлов: 37 добавлений и 127 удалений

Просмотреть файл

@ -425,7 +425,6 @@ nsIXPConnect* nsContentUtils::sXPConnect;
nsIScriptSecurityManager* nsContentUtils::sSecurityManager;
nsIPrincipal* nsContentUtils::sSystemPrincipal;
nsIPrincipal* nsContentUtils::sNullSubjectPrincipal;
nsIPrincipal* nsContentUtils::sFingerprintingProtectionPrincipal;
nsIConsoleService* nsContentUtils::sConsoleService;
static nsTHashMap<RefPtr<nsAtom>, EventNameMapping>* sAtomEventTable;
@ -819,15 +818,6 @@ nsresult nsContentUtils::Init() {
nullPrincipal.forget(&sNullSubjectPrincipal);
RefPtr<nsIPrincipal> fingerprintingProtectionPrincipal =
BasePrincipal::CreateContentPrincipal(
"about:fingerprintingprotection"_ns);
if (!fingerprintingProtectionPrincipal) {
return NS_ERROR_FAILURE;
}
fingerprintingProtectionPrincipal.forget(&sFingerprintingProtectionPrincipal);
if (!InitializeEventTable()) return NS_ERROR_FAILURE;
if (!sEventListenerManagersHash) {
@ -1982,7 +1972,6 @@ void nsContentUtils::Shutdown() {
NS_IF_RELEASE(sSecurityManager);
NS_IF_RELEASE(sSystemPrincipal);
NS_IF_RELEASE(sNullSubjectPrincipal);
NS_IF_RELEASE(sFingerprintingProtectionPrincipal);
sBidiKeyboard = nullptr;

Просмотреть файл

@ -2164,13 +2164,6 @@ class nsContentUtils {
return sNullSubjectPrincipal;
}
/**
* Gets the about:fingerprintingprotection principal.
*/
static nsIPrincipal* GetFingerprintingProtectionPrincipal() {
return sFingerprintingProtectionPrincipal;
}
/**
* *aResourcePrincipal is a principal describing who may access the contents
* of a resource. The resource can only be consumed by a principal that
@ -3648,7 +3641,6 @@ class nsContentUtils {
static nsIScriptSecurityManager* sSecurityManager;
static nsIPrincipal* sSystemPrincipal;
static nsIPrincipal* sNullSubjectPrincipal;
static nsIPrincipal* sFingerprintingProtectionPrincipal;
static nsIConsoleService* sConsoleService;

Просмотреть файл

@ -1121,7 +1121,6 @@ void CanvasRenderingContext2D::GetContextAttributes(
aSettings.mAlpha = mContextAttributesHasAlpha;
aSettings.mWillReadFrequently = mWillReadFrequently;
aSettings.mForceSoftwareRendering = mForceSoftwareRendering;
// We don't support the 'desynchronized' and 'colorSpace' attributes, so
// those just keep their default values.
@ -1472,7 +1471,7 @@ bool CanvasRenderingContext2D::BorrowTarget(const IntRect& aPersistedRect,
// acceleration, then we skip trying to use this provider so that it will be
// recreated by EnsureTarget later.
if (!mBufferProvider || mBufferProvider->RequiresRefresh() ||
(mBufferProvider->IsAccelerated() && UseSoftwareRendering())) {
(mBufferProvider->IsAccelerated() && GetEffectiveWillReadFrequently())) {
return false;
}
mTarget = mBufferProvider->BorrowDrawTarget(aPersistedRect);
@ -1723,7 +1722,7 @@ bool CanvasRenderingContext2D::TryAcceleratedTarget(
}
// Don't try creating an accelerate DrawTarget if either acceleration failed
// previously or if the application expects acceleration to be slow.
if (!mAllowAcceleration || UseSoftwareRendering()) {
if (!mAllowAcceleration || GetEffectiveWillReadFrequently()) {
return false;
}
@ -1780,7 +1779,7 @@ bool CanvasRenderingContext2D::TrySharedTarget(
aOutProvider = renderer->CreatePersistentBufferProvider(
GetSize(), GetSurfaceFormat(),
!mAllowAcceleration || UseSoftwareRendering());
!mAllowAcceleration || GetEffectiveWillReadFrequently());
} else if (mOffscreenCanvas) {
if (!StaticPrefs::gfx_offscreencanvas_shared_provider()) {
return false;
@ -1794,7 +1793,7 @@ bool CanvasRenderingContext2D::TrySharedTarget(
aOutProvider = PersistentBufferProviderShared::Create(
GetSize(), GetSurfaceFormat(), imageBridge,
!mAllowAcceleration || UseSoftwareRendering(),
!mAllowAcceleration || GetEffectiveWillReadFrequently(),
mOffscreenCanvas->GetWindowID());
}
@ -1815,7 +1814,7 @@ bool CanvasRenderingContext2D::TryBasicTarget(
RefPtr<layers::PersistentBufferProvider>& aOutProvider,
ErrorResult& aError) {
aOutDT = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(
GetSize(), GetSurfaceFormat(), UseSoftwareRendering());
GetSize(), GetSurfaceFormat());
if (!aOutDT) {
aError.ThrowInvalidStateError("Canvas could not create basic draw target.");
return false;
@ -2028,7 +2027,6 @@ CanvasRenderingContext2D::SetContextOptions(JSContext* aCx,
}
mWillReadFrequently = attributes.mWillReadFrequently;
mForceSoftwareRendering = attributes.mForceSoftwareRendering;
mContextAttributesHasAlpha = attributes.mAlpha;
UpdateIsOpaque();
@ -6671,10 +6669,9 @@ void CanvasRenderingContext2D::SetWriteOnly() {
}
}
bool CanvasRenderingContext2D::UseSoftwareRendering() const {
return (StaticPrefs::gfx_canvas_willreadfrequently_enabled_AtStartup() &&
mWillReadFrequently) ||
mForceSoftwareRendering;
bool CanvasRenderingContext2D::GetEffectiveWillReadFrequently() const {
return StaticPrefs::gfx_canvas_willreadfrequently_enabled_AtStartup() &&
mWillReadFrequently;
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CanvasPath, mParent)

Просмотреть файл

@ -811,7 +811,7 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal,
return CurrentState().font;
}
bool UseSoftwareRendering() const;
bool GetEffectiveWillReadFrequently() const;
// Member vars
int32_t mWidth, mHeight;
@ -857,8 +857,6 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal,
// Whether the application expects to use operations that perform poorly with
// acceleration.
bool mWillReadFrequently = false;
// Whether to force software rendering
bool mForceSoftwareRendering = false;
// Whether or not we have already shutdown.
bool mHasShutdown = false;
// Whether or not remote canvas is currently unavailable.

Просмотреть файл

@ -769,7 +769,6 @@ void ClientWebGLContext::GetContextAttributes(
result.mPreserveDrawingBuffer = options.preserveDrawingBuffer;
result.mFailIfMajorPerformanceCaveat = options.failIfMajorPerformanceCaveat;
result.mPowerPreference = options.powerPreference;
result.mForceSoftwareRendering = options.forceSoftwareRendering;
}
// -----------------------
@ -1062,7 +1061,6 @@ ClientWebGLContext::SetContextOptions(JSContext* cx,
attributes.mFailIfMajorPerformanceCaveat;
newOpts.xrCompatible = attributes.mXrCompatible;
newOpts.powerPreference = attributes.mPowerPreference;
newOpts.forceSoftwareRendering = attributes.mForceSoftwareRendering;
newOpts.enableDebugRendererInfo =
StaticPrefs::webgl_enable_debug_renderer_info();
MOZ_ASSERT(mCanvasElement || mOffscreenCanvas);
@ -2320,7 +2318,7 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
retval.set(JS::NumberValue(state.mPixelUnpackState.skipRows));
return;
} // switch pname
} // if webgl2
} // if webgl2
// -

Просмотреть файл

@ -287,11 +287,6 @@ bool WebGLContext::CreateAndInitGL(
flags |= gl::CreateContextFlags::FORBID_SOFTWARE;
}
if (mOptions.forceSoftwareRendering) {
flags |= gl::CreateContextFlags::FORBID_HARDWARE;
flags &= ~gl::CreateContextFlags::FORBID_SOFTWARE;
}
if (forceEnabled) {
flags &= ~gl::CreateContextFlags::FORBID_HARDWARE;
flags &= ~gl::CreateContextFlags::FORBID_SOFTWARE;

Просмотреть файл

@ -363,11 +363,9 @@ struct WebGLContextOptions final {
dom::WebGLPowerPreference powerPreference =
dom::WebGLPowerPreference::Default;
std::optional<dom::PredefinedColorSpace> colorSpace;
bool forceSoftwareRendering = false;
bool shouldResistFingerprinting = true;
bool enableDebugRendererInfo = false;
PaddingField<uint8_t, 7> _padding;
auto MutTiedFields() {
// clang-format off
@ -384,12 +382,9 @@ struct WebGLContextOptions final {
powerPreference,
colorSpace,
forceSoftwareRendering,
shouldResistFingerprinting,
enableDebugRendererInfo,
_padding);
enableDebugRendererInfo);
// clang-format on
}

Просмотреть файл

@ -34,9 +34,6 @@ dictionary CanvasRenderingContext2DSettings {
// whether or not we're planning to do a lot of readback operations
boolean willReadFrequently = false;
[Func="nsRFPService::IsSoftwareRenderingOptionExposed"]
boolean forceSoftwareRendering = false;
};
dictionary HitRegionOptions {

Просмотреть файл

@ -56,9 +56,6 @@ dictionary WebGLContextAttributes {
// We are experimenting here, though this should be close to where we end up.
[Pref="webgl.colorspaces.prototype"]
PredefinedColorSpace colorSpace; // = "srgb"; Default is gfx::ColorSpace2::UNKNOWN for now.
[Func="nsRFPService::IsSoftwareRenderingOptionExposed"]
GLboolean forceSoftwareRendering = false;
};
[Exposed=(Window,Worker),

Просмотреть файл

@ -228,7 +228,7 @@ already_AddRefed<GLContext> GLContextEGLFactory::CreateImpl(
gfxCriticalNote << "Failed[3] to load EGL library: " << failureId.get();
return nullptr;
}
const auto egl = lib->CreateDisplay(true, false, &failureId);
const auto egl = lib->CreateDisplay(true, &failureId);
if (!egl) {
gfxCriticalNote << "Failed[3] to create EGL library display: "
<< failureId.get();

Просмотреть файл

@ -887,11 +887,6 @@ static already_AddRefed<GLContextGLX> CreateOffscreenPixmapContext(
auto fullDesc = GLContextDesc{desc};
fullDesc.isOffscreen = true;
if (fullDesc.flags & CreateContextFlags::FORBID_HARDWARE) {
fullDesc.flags |= CreateContextFlags::REQUIRE_COMPAT_PROFILE;
}
return GLContextGLX::CreateGLContext(fullDesc, display, pixmap, config,
drawable);
}

Просмотреть файл

@ -472,9 +472,7 @@ already_AddRefed<GLContext> GLContextProviderWGL::CreateHeadless(
int chosenFormat;
UINT foundFormats = 0;
bool forbidHardware =
static_cast<bool>(desc.flags & CreateContextFlags::FORBID_HARDWARE);
if (!foundFormats && forbidHardware) {
if (!foundFormats) {
const int kAttribs[] = {LOCAL_WGL_DRAW_TO_PBUFFER_ARB,
true,
LOCAL_WGL_SUPPORT_OPENGL_ARB,

Просмотреть файл

@ -868,27 +868,26 @@ std::shared_ptr<EglDisplay> GLLibraryEGL::DefaultDisplay(
auto ret = mDefaultDisplay.lock();
if (ret) return ret;
ret = CreateDisplayLocked(false, false, out_failureId, lock);
ret = CreateDisplayLocked(false, out_failureId, lock);
mDefaultDisplay = ret;
return ret;
}
std::shared_ptr<EglDisplay> GLLibraryEGL::CreateDisplay(
const bool forceAccel, const bool forceSoftware,
nsACString* const out_failureId) {
const bool forceAccel, nsACString* const out_failureId) {
StaticMutexAutoLock lock(sMutex);
return CreateDisplayLocked(forceAccel, forceSoftware, out_failureId, lock);
return CreateDisplayLocked(forceAccel, out_failureId, lock);
}
std::shared_ptr<EglDisplay> GLLibraryEGL::CreateDisplayLocked(
const bool forceAccel, const bool forceSoftware,
nsACString* const out_failureId, const StaticMutexAutoLock& aProofOfLock) {
const bool forceAccel, nsACString* const out_failureId,
const StaticMutexAutoLock& aProofOfLock) {
std::shared_ptr<EglDisplay> ret;
if (IsExtensionSupported(EGLLibExtension::ANGLE_platform_angle_d3d)) {
nsCString accelAngleFailureId;
bool accelAngleSupport = IsAccelAngleSupported(&accelAngleFailureId);
bool shouldTryAccel = (forceAccel || accelAngleSupport) && !forceSoftware;
bool shouldTryAccel = forceAccel || accelAngleSupport;
bool shouldTryWARP = !forceAccel; // Only if ANGLE not supported or fails
// If WARP preferred, will override ANGLE support
@ -933,7 +932,7 @@ std::shared_ptr<EglDisplay> GLLibraryEGL::CreateDisplayLocked(
} else {
void* nativeDisplay = EGL_DEFAULT_DISPLAY;
#ifdef MOZ_WIDGET_GTK
if (!ret && (!gfx::gfxVars::WebglUseHardware() || forceSoftware)) {
if (!ret && !gfx::gfxVars::WebglUseHardware()) {
// Initialize a swrast egl device such as llvmpipe
ret = GetAndInitSoftwareDisplay(*this, aProofOfLock);
}

Просмотреть файл

@ -152,13 +152,13 @@ class GLLibraryEGL final {
void InitLibExtensions();
std::shared_ptr<EglDisplay> CreateDisplayLocked(
bool forceAccel, bool forceSoftware, nsACString* const out_failureId,
bool forceAccel, nsACString* const out_failureId,
const StaticMutexAutoLock& aProofOfLock);
public:
Maybe<SymbolLoader> GetSymbolLoader() const;
std::shared_ptr<EglDisplay> CreateDisplay(bool forceAccel, bool forceSoftware,
std::shared_ptr<EglDisplay> CreateDisplay(bool forceAccel,
nsACString* const out_failureId);
std::shared_ptr<EglDisplay> CreateDisplay(ID3D11Device*);
std::shared_ptr<EglDisplay> DefaultDisplay(nsACString* const out_failureId);

Просмотреть файл

@ -312,15 +312,13 @@ static TextureType ChooseTextureType(gfx::SurfaceFormat aFormat,
#endif
#ifdef XP_MACOSX
if (StaticPrefs::gfx_use_iosurface_textures_AtStartup() &&
!aKnowsCompositor->UsingSoftwareWebRender()) {
if (StaticPrefs::gfx_use_iosurface_textures_AtStartup()) {
return TextureType::MacIOSurface;
}
#endif
#ifdef MOZ_WIDGET_ANDROID
if (StaticPrefs::gfx_use_surfacetexture_textures_AtStartup() &&
!aKnowsCompositor->UsingSoftwareWebRender()) {
if (StaticPrefs::gfx_use_surfacetexture_textures_AtStartup()) {
return TextureType::AndroidNativeWindow;
}
#endif
@ -1494,7 +1492,6 @@ already_AddRefed<TextureClient> TextureClient::CreateForRawBufferAccess(
aMoz2DBackend == gfx::BackendType::DIRECT2D1_1,
"Unsupported TextureClient backend type");
// For future changes, check aAllocFlags aAllocFlags & ALLOC_DO_NOT_ACCELERATE
TextureData* texData = BufferTextureData::Create(
aSize, aFormat, gfx::BackendType::SKIA, aLayersBackend, aTextureFlags,
aAllocFlags, aAllocator);

Просмотреть файл

@ -1678,35 +1678,19 @@ already_AddRefed<DrawTarget> gfxPlatform::CreateDrawTargetForBackend(
}
already_AddRefed<DrawTarget> gfxPlatform::CreateOffscreenCanvasDrawTarget(
const IntSize& aSize, SurfaceFormat aFormat, bool aRequireSoftwareRender) {
const IntSize& aSize, SurfaceFormat aFormat) {
NS_ASSERTION(mPreferredCanvasBackend != BackendType::NONE, "No backend.");
BackendType backend = mFallbackCanvasBackend;
// If we are using remote canvas we don't want to use acceleration in
// canvas DrawTargets we are not remoting, so we always use the fallback
// software one.
if (!gfxPlatform::UseRemoteCanvas() ||
!gfxPlatform::IsBackendAccelerated(mPreferredCanvasBackend)) {
backend = mPreferredCanvasBackend;
}
if (aRequireSoftwareRender) {
backend = gfxPlatform::IsBackendAccelerated(mPreferredCanvasBackend)
? mFallbackCanvasBackend
: mPreferredCanvasBackend;
}
#ifdef XP_WIN
// On Windows, the fallback backend (Cairo) should use its image backend.
RefPtr<DrawTarget> target =
Factory::CreateDrawTarget(backend, aSize, aFormat);
#else
RefPtr<DrawTarget> target =
CreateDrawTargetForBackend(backend, aSize, aFormat);
#endif
if (target || mFallbackCanvasBackend == BackendType::NONE) {
return target.forget();
RefPtr<DrawTarget> target =
CreateDrawTargetForBackend(mPreferredCanvasBackend, aSize, aFormat);
if (target || mFallbackCanvasBackend == BackendType::NONE) {
return target.forget();
}
}
#ifdef XP_WIN

Просмотреть файл

@ -265,8 +265,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
bool aFallback = false);
already_AddRefed<DrawTarget> CreateOffscreenCanvasDrawTarget(
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat,
bool aRequireSoftwareRender = false);
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
already_AddRefed<DrawTarget> CreateSimilarSoftwareDrawTarget(
DrawTarget* aDT, const IntSize& aSize,
@ -344,7 +343,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
* available fonts on the platform; used to pass the list from chrome to
* content process. Currently implemented only on MacOSX and Linux.
*/
virtual void ReadSystemFontList(mozilla::dom::SystemFontList*) {};
virtual void ReadSystemFontList(mozilla::dom::SystemFontList*){};
/**
* Rebuilds the system font lists (if aFullRebuild is true), or just notifies
@ -780,7 +779,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
virtual void OnMemoryPressure(
mozilla::layers::MemoryPressureReason aWhy) override;
virtual void EnsureDevicesInitialized() {};
virtual void EnsureDevicesInitialized(){};
virtual bool DevicesInitialized() { return true; };
virtual bool IsWaylandDisplay() { return false; }

Просмотреть файл

@ -160,7 +160,7 @@ export class UserCharacteristicsPageService {
shutdown() {}
createContentPage(principal) {
createContentPage() {
lazy.console.debug("called createContentPage");
lazy.console.debug("Registering actor");
@ -184,6 +184,7 @@ export class UserCharacteristicsPageService {
let { promise, resolve } = Promise.withResolvers();
this._backgroundBrowsers.set(browser, resolve);
let principal = Services.scriptSecurityManager.getSystemPrincipal();
let loadURIOptions = {
triggeringPrincipal: principal,
};

Просмотреть файл

@ -3,7 +3,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIPrincipal.idl"
webidl BrowsingContext;
@ -14,7 +13,7 @@ interface nsIUserCharacteristicsPageService : nsISupports {
* Create the UserCharacteristics about: page as a HiddenFrame
* and begin the data collection.
*/
Promise createContentPage(in nsIPrincipal principal);
Promise createContentPage();
/*
* Called when the UserCharacteristics about: page has been loaded

Просмотреть файл

@ -1888,22 +1888,6 @@ bool nsRFPService::CheckSuspiciousFingerprintingActivity(
return cnt > kSuspiciousFingerprintingActivityThreshold;
}
/* static */
bool nsRFPService::IsSoftwareRenderingOptionExposed(JSContext* aCx,
JSObject* aObj) {
if (!NS_IsMainThread()) {
return false;
}
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aObj);
if (nsContentUtils::SubjectPrincipal(aCx)->IsSystemPrincipal()) {
return true;
}
return principal->Equals(
nsContentUtils::GetFingerprintingProtectionPrincipal());
}
/* static */
nsresult nsRFPService::CreateOverrideDomainKey(
nsIFingerprintingOverride* aOverride, nsACString& aDomainKey) {

Просмотреть файл

@ -221,8 +221,6 @@ class nsRFPService final : public nsIObserver, public nsIRFPService {
bool aIsPrivateMode, RFPTarget aTarget,
const Maybe<RFPTarget>& aOverriddenFingerprintingSettings);
static bool IsSoftwareRenderingOptionExposed(JSContext*, JSObject*);
// --------------------------------------------------------------------------
static double TimerResolution(RTPCallerType aRTPCallerType);

Просмотреть файл

@ -109,9 +109,7 @@ RefPtr<PopulatePromise> ContentPageStuff() {
RefPtr<PopulatePromise> populatePromise = new PopulatePromise(__func__);
RefPtr<mozilla::dom::Promise> promise;
nsresult rv = ucp->CreateContentPage(
nsContentUtils::GetFingerprintingProtectionPrincipal(),
getter_AddRefs(promise));
nsresult rv = ucp->CreateContentPage(getter_AddRefs(promise));
if (NS_FAILED(rv)) {
MOZ_LOG(gUserCharacteristicsLog, mozilla::LogLevel::Error,
("Could not create Content Page"));