Resolved: Modifying webview src crashes electron app without warning/error in electron 1.6.x


#1

Hi,

I am trying to upgrade my electron from 1.4.15[electron-prebuild] to electron 1.6.x
After my upgrade when i apply jquery in devtools i am not getting correct result, sometimes it break application also.

query used in electron 1.6.x via devtools : $('#url')

Actual o/p:
r.fn.init[1]0:webview#variationDebuggerUrl.tabs-panelength:1__proto__:Object[0]

Expected o/p:
<webview class="tabs-pane" id="url" webpreferences="allowRunningInsecureContent" autosize="" minwidth="1100" minheight="790" plugins="" disablewebsecurity="" src="Url" tabindex="-1" guestinstance="4"></webview>

If i edit query as :$(’#url’)[0] I am getting proper result

<webview class="tabs-pane" id="url" webpreferences="allowRunningInsecureContent" autosize="" minwidth="1100" minheight="790" plugins="" disablewebsecurity="" src="Url" tabindex="-1" guestinstance="4"></webview>

If i try to insert value to src,
$('#url').attr('src','www.example.com')
$('#url')[0].attr('src','www.example.com')

application is crashing/closing without any warning

The same syntax $('#url').attr('src','www.example.com') was working fine in electron-prebuild-1.4.15

Can any one help me to fix this issue

Thanks
Jk


#2

you have a guestinstance="4" on the property list, are you doing this on purpose?
If it’s not, removing this may solve your problem


#3

@hkuclion : Thanks for you suggestion.
My HTML dont have that attribute 'guestinstance', it is auto generated.

HTML:

<webview class="tabs-pane" id="csiUrl" allowpopups webpreferences='allowRunningInsecureContent' autosize minwidth="1100" minheight="790" plugins disablewebsecurity src="Url"></webview>

Is there any settings to remove that

Update:

@hkuclion Your suggestion is correct, we need to remove that guestinstance, Currently I am doing it using Jquery, however I am not sure why that property is attached to my webview.


#4
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.1.min.js"></script>

<webview class="tabs-pane" id="csiUrl" allowpopups webpreferences='allowRunningInsecureContent' autosize minwidth="1100" minheight="790" plugins disablewebsecurity src="Url"></webview>
<script>
	module.exports('#csiUrl').attr('src','http://www.baidu.com');
</script>

code like this works on my Windows10, electron 1.6.2.
the page is loaded except the actual width and height is not enough to fit minwidth & minheight


#5

I found the the issue , my issue is same as https://github.com/electron/electron/issues/3096

Fix

setTimeout(function () {
    $('#csiUrl').attr('src', val);
}, 20);