Unverified Commit a5c60f41 authored by Rulong Chen(陈汝龙)'s avatar Rulong Chen(陈汝龙) Committed by GitHub

Limit the PlatformView ID within the range of 32-bit integers. (#121203)

Limit the PlatformView ID within the range of 32-bit integers.
parent fbae472f
......@@ -44,7 +44,16 @@ class PlatformViewsRegistry {
///
/// Typically a platform view identifier is passed to a platform view widget
/// which creates the platform view and manages its lifecycle.
int getNextPlatformViewId() => _nextPlatformViewId++;
int getNextPlatformViewId() {
// On the Android side, the interface exposed to users uses 32-bit integers.
// See https://github.com/flutter/engine/pull/39476 for more details.
// We can safely assume that a Flutter application will not require more
// than MAX_INT32 platform views during its lifetime.
const int MAX_INT32 = 0x7FFFFFFF;
assert(_nextPlatformViewId <= MAX_INT32);
return _nextPlatformViewId++;
}
}
/// Callback signature for when a platform view was created.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment