Tencent/QMUI_Android · error · Error
message == null
Error message
message == null
What it means
In QMUIWebviewBridge.js, the send(data, callback) function is the bridge's message dispatcher. It throws Error("message == null") when data is falsy (null, undefined, or empty), because an empty message cannot be serialized or dispatched to the native side.
Source
Thrown at qmui/src/main/assets/QMUIWebviewBridge.js:23
}
var messagingIframe = createIframe(doc);
var sendingMessageQueue = [];
var receivedMessageQueue = [];
var messageHandlers = {};
var QUEUE_HAS_MESSAGE = 'qmui://__QUEUE_MESSAGE__/';
var responseCallbacks = {};
var uuid = 1;
function createIframe(doc) {
var iframe = doc.createElement('iframe');
iframe.style.display = 'none';
doc.documentElement.appendChild(iframe);
return iframe;
}
function send(data, callback) {
if(!data){
throw new Error("message == null")
}
var message = {
data: data
}
if(callback){
var callbackId = 'cb_' + (uuid++) + '_' + (new Date() - 0);
responseCallbacks[callbackId] = callback;
message.callbackId = callbackId;
}
sendingMessageQueue.push(message);
messagingIframe.src = QUEUE_HAS_MESSAGE;
}
function isCmdSupport(cmd, callback){
if(isCmdSupport.__cache && isCmdSupport.__cache.indexOf(cmd) >= 0){
callback(true)
return
}View on GitHub (pinned to 026e7d4866)
Solutions
- Ensure a non-empty data object is built before calling send.
- Check for undefined/empty values at the call site and bail out early.
- Inspect getSupportedCmdList and other internal send() callers to verify they always construct a payload.
Example fix
// before
bridge.send(msg) // msg may be undefined
// after
if (msg) { bridge.send(msg) } else { console.warn('skip empty bridge message') } Defensive patterns
Strategy: validation
Validate before calling
function safeSend(bridge, data, cb) { if (!data) { console.warn('empty bridge message'); return } bridge.send(data, cb) } Type guard
function isBridgeMessage(d) { return d !== null && d !== undefined && d !== '' } Try / catch
try { bridge.send(data, cb) } catch (e) { console.error('bridge send failed', e) } Prevention
- Build the message payload before calling send
- Assert payload non-empty in a wrapper
- Trace data sources that may resolve to undefined
When it happens
Trigger: Calling send(null/undefined/'') directly, or indirectly via getSupportedCmdList if the command payload construction yields an empty/falsy data value.
Common situations: JS page calls bridge.send() before building the message object; variable holding the message is undefined due to a typo or failed fetch; empty response passed through to the bridge.
Related errors
- Parameter:activity must not be null
- Parameter:listener must not be null
- must use the instance of QMUIWebViewClient
- not a inner api message. fallback to custom message
AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06).
Data as JSON: /api/errors/2ea7774f2cb2970b.
Report an issue: GitHub.