mlapptools
mlapptools copied to clipboard
Error using mlapptools.getWebElements
Summary
I am having troubles when using the following function : [win, widgetID] = mlapptools.getWebElements(app.TabGroup);
The issue is quite random. I can have issue 1 or issue 2, you can find below. I don't understand any of them. About issue 2 I looked what has been said about it on Matlab forum, like upgrade driver etc.. But I did it, tried the function on several computer and I still have it.
Problem Description
Issue 1 :
Issue 2 :
MATLAB crash file:C:\Users\hserus\AppData\Local\Temp\matlab_crash_dump.22480-1:
--------------------------------------------------------------------------------
Access violation detected at mar. oct. 09 11:43:01 2018 +0200
--------------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : false
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) HD Graphics 520 Version 23.20.16.4973 (2018-2-28)
Java Version : Java 1.8.0_152-b16 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 3250676
MATLAB Root : C:\Program Files\MATLAB\R2018b
MATLAB Version : 9.5.0.944444 (R2018b)
OpenGL : hardware
Operating System : Microsoft Windows 10 Professionnel
Process ID : 22480
Processor ID : x86 Family 6 Model 78 Stepping 3, GenuineIntel
Session Key : 7c2dcbac-278d-4f02-8001-dac683515e68
Window System : Version 10.0 (Build 17134)
Fault Count: 1
Abnormal termination
Register State (from fault):
RAX = 000000000cf85b7e RBX = 0000000300000000
RCX = 0000000005f87ac0 RDX = 0000000000000003
RSP = 00000000043f14c0 RBP = 0000000005f87ac0
RSI = 0000000005f86be0 RDI = 000000000cf85b6f
R8 = 0000000000000001 R9 = 0000000005f87ac0
R10 = 000000004393e188 R11 = 00000000043f1560
R12 = 0000000000000003 R13 = 000000003248cd00
R14 = 0000000000000002 R15 = 0000000000000000
RIP = 0000000180004c96 EFL = 00010203
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x0000000180004c96 bin\win64\pgo\libmx.dll+00019606 matrix::detail::noninlined::mx_array_api::mxUnshare+00004650
[ 1] 0x000000018000de19 bin\win64\pgo\libmx.dll+00056857 matrix::detail::noninlined::mx_array_api::mxPreparePropertyValueForContainment+00000217
[ 2] 0x000000018000246d bin\win64\pgo\libmx.dll+00009325 matrix::detail::noninlined::mx_array_api::mxSetFieldByNumber+00000133
[ 3] 0x00000000326e7a3c bin\win64\pgo\mcos_impl.dll+02849340 mwboost::serialization::singleton_module::unlock+01552008
[ 4] 0x0000000032480c12 bin\win64\pgo\mcos_impl.dll+00330770
[ 5] 0x000000003247ba69 bin\win64\pgo\mcos_impl.dll+00309865
[ 6] 0x00000000326e2719 bin\win64\pgo\mcos_impl.dll+02828057 mwboost::serialization::singleton_module::unlock+01530725
[ 7] 0x0000000180039b5c bin\win64\pgo\libmx.dll+00236380 mxArray_tag::operator delete+00040924
[ 8] 0x0000000180010296 bin\win64\pgo\libmx.dll+00066198 matrix::detail::noninlined::mx_array_api::mxMustBe+00000138
[ 9] 0x00000000e63916fa bin\win64\cellstructconversion.dll+00005882
[ 10] 0x000000001b33b724 bin\win64\pgo\m_dispatcher.dll+00046884 Mdispatcher::getDispatcher+00002228
[ 11] 0x000000001b33cbe7 bin\win64\pgo\m_dispatcher.dll+00052199 Mfh_MATLAB_fn_impl::dispatch_fh+00000343
[ 12] 0x000000001c1268f2 bin\win64\pgo\m_lxe.dll+00420082
[ 13] 0x000000001c20fd3c bin\win64\pgo\m_lxe.dll+01375548 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00493568
[ 14] 0x000000001c21091c bin\win64\pgo\m_lxe.dll+01378588 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00496608
[ 15] 0x000000001c211c92 bin\win64\pgo\m_lxe.dll+01383570 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00501590
[ 16] 0x000000001c2128f8 bin\win64\pgo\m_lxe.dll+01386744 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00504764
[ 17] 0x000000001c211ddf bin\win64\pgo\m_lxe.dll+01383903 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00501923
[ 18] 0x000000001c211ede bin\win64\pgo\m_lxe.dll+01384158 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00502178
[ 19] 0x000000001c119a7d bin\win64\pgo\m_lxe.dll+00367229
[ 20] 0x000000001c12b265 bin\win64\pgo\m_lxe.dll+00438885
[ 21] 0x000000001c128e26 bin\win64\pgo\m_lxe.dll+00429606
[ 22] 0x000000001c128a24 bin\win64\pgo\m_lxe.dll+00428580
[ 23] 0x000000001b33e007 bin\win64\pgo\m_dispatcher.dll+00057351 Mfh_file::dispatch_fh_impl+00001111
[ 24] 0x000000001b33daf2 bin\win64\pgo\m_dispatcher.dll+00056050 Mfh_file::dispatch_fh_with_reuse+00000066
[ 25] 0x0000000032499dc3 bin\win64\pgo\mcos_impl.dll+00433603
[ 26] 0x0000000032494826 bin\win64\pgo\mcos_impl.dll+00411686
[ 27] 0x000000003249347f bin\win64\pgo\mcos_impl.dll+00406655
[ 28] 0x000000003249234b bin\win64\pgo\mcos_impl.dll+00402251
[ 29] 0x0000000032492130 bin\win64\pgo\mcos_impl.dll+00401712
[ 30] 0x0000000032491a3a bin\win64\pgo\mcos_impl.dll+00399930
[ 31] 0x000000001b33ca07 bin\win64\pgo\m_dispatcher.dll+00051719 Mfh_MATLAB_fn_impl::dispatch_fh_with_reuse+00000343
[ 32] 0x000000001c1e263c bin\win64\pgo\m_lxe.dll+01189436 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00307456
[ 33] 0x000000001c11b8e7 bin\win64\pgo\m_lxe.dll+00375015
[ 34] 0x000000001dbee1a1 bin\win64\pgo\m_lxe.dll+28500385 mwboost::archive::detail::pointer_oserializer<mwboost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00359557
[ 35] 0x000000001dbf729f bin\win64\pgo\m_lxe.dll+28537503 mwboost::archive::detail::pointer_oserializer<mwboost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00396675
[ 36] 0x000000001c20fbfe bin\win64\pgo\m_lxe.dll+01375230 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00493250
[ 37] 0x000000001c21091c bin\win64\pgo\m_lxe.dll+01378588 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00496608
[ 38] 0x000000001c211c92 bin\win64\pgo\m_lxe.dll+01383570 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00501590
[ 39] 0x000000001c2128f8 bin\win64\pgo\m_lxe.dll+01386744 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00504764
[ 40] 0x000000001c211ddf bin\win64\pgo\m_lxe.dll+01383903 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00501923
[ 41] 0x000000001c211ede bin\win64\pgo\m_lxe.dll+01384158 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00502178
[ 42] 0x000000001c119a7d bin\win64\pgo\m_lxe.dll+00367229
[ 43] 0x000000001c12b265 bin\win64\pgo\m_lxe.dll+00438885
[ 44] 0x000000001c128e26 bin\win64\pgo\m_lxe.dll+00429606
[ 45] 0x000000001c128a24 bin\win64\pgo\m_lxe.dll+00428580
[ 46] 0x000000001b33e007 bin\win64\pgo\m_dispatcher.dll+00057351 Mfh_file::dispatch_fh_impl+00001111
[ 47] 0x000000001b33daf2 bin\win64\pgo\m_dispatcher.dll+00056050 Mfh_file::dispatch_fh_with_reuse+00000066
[ 48] 0x0000000032499dc3 bin\win64\pgo\mcos_impl.dll+00433603
[ 49] 0x0000000032494826 bin\win64\pgo\mcos_impl.dll+00411686
[ 50] 0x000000003249347f bin\win64\pgo\mcos_impl.dll+00406655
[ 51] 0x000000003249234b bin\win64\pgo\mcos_impl.dll+00402251
[ 52] 0x0000000032492130 bin\win64\pgo\mcos_impl.dll+00401712
[ 53] 0x0000000032491a3a bin\win64\pgo\mcos_impl.dll+00399930
[ 54] 0x000000001b33ca07 bin\win64\pgo\m_dispatcher.dll+00051719 Mfh_MATLAB_fn_impl::dispatch_fh_with_reuse+00000343
[ 55] 0x000000001c1e263c bin\win64\pgo\m_lxe.dll+01189436 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00307456
[ 56] 0x000000001c11b8e7 bin\win64\pgo\m_lxe.dll+00375015
[ 57] 0x000000001c2db5b9 bin\win64\pgo\m_lxe.dll+02209209 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,std::vector<MathWorks::utl::attach_ptr<ir::IrTree>,std::allocator<MathWorks::utl::attach_ptr<ir::IrTree> > > >::load_object_data+00032749
[ 58] 0x000000001c114ceb bin\win64\pgo\m_lxe.dll+00347371
[ 59] 0x000000001c2a5cb3 bin\win64\pgo\m_lxe.dll+01989811 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+01107831
[ 60] 0x000000001c2a5c35 bin\win64\pgo\m_lxe.dll+01989685 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+01107705
[ 61] 0x000000001c20fd3c bin\win64\pgo\m_lxe.dll+01375548 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00493568
[ 62] 0x000000001c21091c bin\win64\pgo\m_lxe.dll+01378588 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00496608
[ 63] 0x000000001c211c92 bin\win64\pgo\m_lxe.dll+01383570 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00501590
[ 64] 0x000000001c2128f8 bin\win64\pgo\m_lxe.dll+01386744 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00504764
[ 65] 0x000000001c211ddf bin\win64\pgo\m_lxe.dll+01383903 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00501923
[ 66] 0x000000001c211ede bin\win64\pgo\m_lxe.dll+01384158 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00502178
[ 67] 0x000000001c119a7d bin\win64\pgo\m_lxe.dll+00367229
[ 68] 0x000000001c12b265 bin\win64\pgo\m_lxe.dll+00438885
[ 69] 0x000000001c12a88c bin\win64\pgo\m_lxe.dll+00436364
[ 70] 0x000000001c12447d bin\win64\pgo\m_lxe.dll+00410749
[ 71] 0x000000001c123875 bin\win64\pgo\m_lxe.dll+00407669
[ 72] 0x000000001c1234bc bin\win64\pgo\m_lxe.dll+00406716
[ 73] 0x000000001c123268 bin\win64\pgo\m_lxe.dll+00406120
[ 74] 0x000000001c1e32e8 bin\win64\pgo\m_lxe.dll+01192680 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00310700
[ 75] 0x000000001d7fdbda bin\win64\pgo\m_lxe.dll+24370138 mwboost::serialization::singleton<mwboost::archive::detail::extra_detail::guid_initializer<MathWorks::lxe::CodeClearEvent> >::get_mutable_instance+21916030
[ 76] 0x000000001bcf16a5 bin\win64\pgo\m_interpreter.dll+00071333 inRunSaveObjFunction+00000313
[ 77] 0x000000001b33b724 bin\win64\pgo\m_dispatcher.dll+00046884 Mdispatcher::getDispatcher+00002228
[ 78] 0x000000001b33cbe7 bin\win64\pgo\m_dispatcher.dll+00052199 Mfh_MATLAB_fn_impl::dispatch_fh+00000343
[ 79] 0x000000001c1268f2 bin\win64\pgo\m_lxe.dll+00420082
[ 80] 0x000000001c20fd3c bin\win64\pgo\m_lxe.dll+01375548 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00493568
[ 81] 0x000000001c21091c bin\win64\pgo\m_lxe.dll+01378588 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00496608
[ 82] 0x000000001c211c92 bin\win64\pgo\m_lxe.dll+01383570 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00501590
[ 83] 0x000000001c2128f8 bin\win64\pgo\m_lxe.dll+01386744 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00504764
[ 84] 0x000000001c211ddf bin\win64\pgo\m_lxe.dll+01383903 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00501923
[ 85] 0x000000001c211ede bin\win64\pgo\m_lxe.dll+01384158 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00502178
[ 86] 0x000000001c119a7d bin\win64\pgo\m_lxe.dll+00367229
[ 87] 0x000000001c12b265 bin\win64\pgo\m_lxe.dll+00438885
[ 88] 0x000000001c12a88c bin\win64\pgo\m_lxe.dll+00436364
[ 89] 0x000000001c1f470a bin\win64\pgo\m_lxe.dll+01263370 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00381390
[ 90] 0x000000001c1263ab bin\win64\pgo\m_lxe.dll+00418731
[ 91] 0x000000001c1f455c bin\win64\pgo\m_lxe.dll+01262940 mwboost::archive::detail::iserializer<mwboost::archive::binaryTerm_iarchive,MathWorks::lxe::function_descriptor>::load_object_data+00380960
[ 92] 0x000000000b2f463b C:\Program Files\MATLAB\R2018b\toolbox\matlab\appdesigner\appdesigner\+appdesigner\+internal\+serialization\defer.mexw64+00149051
[ 93] 0x000000000b2d967d C:\Program Files\MATLAB\R2018b\toolbox\matlab\appdesigner\appdesigner\+appdesigner\+internal\+serialization\defer.mexw64+00038525
[ 94] 0x000000000b2ee8f4 C:\Program Files\MATLAB\R2018b\toolbox\matlab\appdesigner\appdesigner\+appdesigner\+internal\+serialization\defer.mexw64+00125172
[ 95] 0x00000000fd02cfee bin\win64\iqm.dll+00643054 iqm::PackagedTaskPlugin::execute+00000894
[ 96] 0x00000000fd02ce63 bin\win64\iqm.dll+00642659 iqm::PackagedTaskPlugin::execute+00000499
[ 97] 0x000000001b1741fb bin\win64\mcr.dll+00541179 mcrRegisterExternalFunction+00041003
[ 98] 0x00000000fcffcc07 bin\win64\iqm.dll+00445447 iqm::Iqm::setupIqmFcnPtrs+00076215
[ 99] 0x00000000fcffcc59 bin\win64\iqm.dll+00445529 iqm::Iqm::setupIqmFcnPtrs+00076297
[100] 0x00000000fcffca16 bin\win64\iqm.dll+00444950 iqm::Iqm::setupIqmFcnPtrs+00075718
[101] 0x00000000fcfd888d bin\win64\iqm.dll+00297101 iqm::Iqm::deliver+00002109
[102] 0x00000000fb5fe634 bin\win64\libmwbridge.dll+00058932 ioReadLine+00000772
[103] 0x00000000fb5fe3fd bin\win64\libmwbridge.dll+00058365 ioReadLine+00000205
[104] 0x00000000fb60fd4b bin\win64\libmwbridge.dll+00130379 mnDebugPrompt+00002155
[105] 0x00000000fb60f615 bin\win64\libmwbridge.dll+00128533 mnDebugPrompt+00000309
[106] 0x00000000fb6100b4 bin\win64\libmwbridge.dll+00131252 mnParser+00000580
[107] 0x000000001b143618 bin\win64\mcr.dll+00341528 mcr::runtime::setInterpreterThreadSingletonToCurrent+00020808
[108] 0x000000001b14414d bin\win64\mcr.dll+00344397 mcr::runtime::setInterpreterThreadSingletonToCurrent+00023677
[109] 0x000000001b10b1ba bin\win64\mcr.dll+00111034 mcrOptions::set_use_license_manager+00075498
[110] 0x000000001b126e74 bin\win64\mcr.dll+00224884 mcrOptions::set_use_license_manager+00189348
[111] 0x00000000fd02cfee bin\win64\iqm.dll+00643054 iqm::PackagedTaskPlugin::execute+00000894
[112] 0x00000000fd02ce63 bin\win64\iqm.dll+00642659 iqm::PackagedTaskPlugin::execute+00000499
[113] 0x00000000fcffcc07 bin\win64\iqm.dll+00445447 iqm::Iqm::setupIqmFcnPtrs+00076215
[114] 0x00000000fcffcc59 bin\win64\iqm.dll+00445529 iqm::Iqm::setupIqmFcnPtrs+00076297
[115] 0x00000000fcffca16 bin\win64\iqm.dll+00444950 iqm::Iqm::setupIqmFcnPtrs+00075718
[116] 0x00000000fcfd9748 bin\win64\iqm.dll+00300872 iqm::Iqm::deliver+00005880
[117] 0x00000000fcfd8eef bin\win64\iqm.dll+00298735 iqm::Iqm::deliver+00003743
[118] 0x00000000fcfdac0d bin\win64\iqm.dll+00306189 iqm::Iqm::deliver+00011197
[119] 0x0000000100203775 bin\win64\libmwservices.dll+02176885 services::system_events::PpeDispatchHook::dispatchOne+00036213
[120] 0x0000000100212a63 bin\win64\libmwservices.dll+02239075 sysq::addProcessPendingEventsUnitTestHook+00006035
[121] 0x0000000100214310 bin\win64\libmwservices.dll+02245392 sysq::getCondition+00004208
[122] 0x000000010021596d bin\win64\libmwservices.dll+02251117 svWS_ProcessPendingEvents+00000221
[123] 0x000000001b147724 bin\win64\mcr.dll+00358180 mcr::runtime::setInterpreterThreadSingletonToCurrent+00037460
[124] 0x000000001b147f16 bin\win64\mcr.dll+00360214 mcr::runtime::setInterpreterThreadSingletonToCurrent+00039494
[125] 0x000000001b13cabf bin\win64\mcr.dll+00314047 mcr_process_events+00001007
[126] 0x000000001b04d040 bin\win64\MVMLocal.dll+00380992 mvm_server::inproc::LocalFactory::terminate+00177312
[127] 0x00000000fa9d9480 bin\win64\mvm.dll+01741952 mvm::detail::SessionImpl::initWithOptions+00000592
Specifications
- MATLAB Release: R2018b
- Operating System: Windows 10
mlapptoolsversion 2018
Regarding the first issue, as the error says - more time needs to pass between the creation of the UIFigure and running mlapptools. Here's what you can try:
- Set a longer timeout:
mlapptools.setTimeout(hUIFig, 10);(try15,20etc. if10doesn't work for you). - Add a
pausebefore callingmlapptools(so for example:pause(5); mlapptools.getWebElements(...)).
Regarding the 2nd issue - when exactly does it happen? When you run the code, or after you close a uifigure? Please provide exact steps to reproduce. If you need to upload a .mlapp file, please do so. I have R2018a and R2018b so I can test it locally.
Thank you for your answer @Dev-iL . To answer your remarks :
Set a longer timeout: mlapptools.setTimeout(hUIFig, 10); (try 15, 20 etc. if 10 doesn't work for you). Add a pause before calling mlapptools (so for example: pause(5); mlapptools.getWebElements(...)).
I tested what you say but the issue n°2 is now showing 100% of the time...
Regarding the 2nd issue - when exactly does it happen? When you run the code, or after you close a uifigure? Please provide exact steps to reproduce. If you need to upload a .mlapp file, please do so. I have R2018a and R2018b so I can test it locally.
It happens just after starting the interface (3 -4 seconds of delay). Actually, the [win, widgetID] = mlapptools.getWebElements(app.TabGroup) function is in the startUpFcn.
I give you my code (I would prefer in private) but you will have many parts missing...
Thanks
@thiblab Please try to create a new App with just the minimum code required to reproduce the issue, then post the code of the App here.
Did you try saving the code of the App in a regular .m file and running it? I suspect that this issue happens because you run the code from within the App Designer.
The issue 2 seems indeed appear only with App Designer. So in which conditions I have to use mlappTools ? When using the code of App Designer but not using App Designer itself ?
Yes, I would say that this is a sound course of action (at least that's how I always use it, because I used to have various problem running App Designer, so I ended up creating UIFigures completely programmatically)...
You see, the App Designer itself is a uifigure (and hence, a "browser window"), so there must be some issues when we try making MATLAB have two browser windows communicating with each other.
Sorry, I replied too fast. Below is a simple code that I am running as .m file. And unfortunately, the issue 2 is still showing...
The behavior is actually strange : Sometimes it works, and when it works both [win, widgetID] are returned. When it crashes the widgetID isn't return so it seems that the issue come from this parameter.
classdef app2 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
TabGroup matlab.ui.container.TabGroup
Tab matlab.ui.container.Tab
Tab2 matlab.ui.container.Tab
end
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
[win, widgetID] = mlapptools.getWebElements(app.TabGroup)
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
% Create TabGroup
app.TabGroup = uitabgroup(app.UIFigure);
app.TabGroup.Position = [100 82 325 280];
% Create Tab
app.Tab = uitab(app.TabGroup);
app.Tab.Title = 'Tab';
% Create Tab2
app.Tab2 = uitab(app.TabGroup);
app.Tab2.Title = 'Tab2';
end
end
methods (Access = public)
% Construct app
function app = app2
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
I can reproduce your problem.
If your use-case permits it, I suggest you only take the code that creates components (and callbacks if there are any), then apply your customizations at the end.
%% Create UIFigure and add components:
app = struct(); % < This is just to keep the same structure for the rest of the code.
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
% Create TabGroup
app.TabGroup = uitabgroup(app.UIFigure);
app.TabGroup.Position = [100 82 325 280];
% Create Tab
app.Tab = uitab(app.TabGroup);
app.Tab.Title = 'Tab';
% Create Tab2
app.Tab2 = uitab(app.TabGroup);
app.Tab2.Title = 'Tab2';
%% Customize using mlapptools:
pause(5); % might need to be longer, depending on your computer.
[win, widgetID] = mlapptools.getWebElements(app.TabGroup);
...
In conclusion - until we find a way to better way to avoid these crashes, you should only use mlapptools after your uifigure was fully created (just like in the examples).
Thanks for your answer, but actually it has fixed the issue. I can put pause(30) or more, sometimes it's still crashing. I don't get why it does this, in both cases the component are already created right ? So what would be the inherent problem ?
Actually, I want to be able to personalize the Tab Group (cf screenshot) (Size of click panel, Selected / Unselected Color, Font, Font Size, Underlying...). Am I able to do this with mlappTools ?
I didn't try doing anything like that myself, but I expect that it is possible, yes. I would also advise you to use the documented ways to edit components as much as possible, and only when you reach their limit, switch to mlapptools.
Actually, the documented way doesn't offer any possibility to customize the TabGroup object. This is Why I wanted to try mlapptools.
Today I tried the 'manual' way to retrieve tags and ID and the issue is the same, and appear only with the TabGroup object but works fine with other objects. Here is the code if you want to reproduce it. The URL is found, but the script crashes when retrieving the tag of the associated TabGroup.
classdef DOMdemo < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure % UI Figure
LabelTextArea matlab.ui.control.Label % Text Area
TextArea matlab.ui.control.TextArea % This is some text.
TabGroup matlab.ui.container.TabGroup
Tab matlab.ui.container.Tab
Tab2 matlab.ui.container.Tab
end
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
% Customizations (aka "MAGIC GOES HERE"):
warning off Matlab:HandleGraphics:ObsoletedProperty:JavaFrame
warning off Matlab:structOnObject
while true
try
win = struct(struct(struct(app.UIFigure).Controller).PlatformHost).CEF;
disp(win.URL)
data_tag = char(struct(app.TabGroup).Controller.ProxyView.PeerNode.getId)
widgetId = win.executeJS(['dojo.getAttr(dojo.query("[data-tag^=''' data_tag '''] > div")[0],"widgetid")']);
break
catch
disp('Not ready yet!');
pause(0.5); % Give the figure (webpage) some more time to load
end
end
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 500 500];
app.UIFigure.Name = 'UI Figure';
setAutoResize(app, app.UIFigure, true)
% Create LabelTextArea
app.LabelTextArea = uilabel(app.UIFigure);
app.LabelTextArea.HorizontalAlignment = 'right';
app.LabelTextArea.Position = [16 73 62 15];
app.LabelTextArea.Text = 'Text Area';
% Create TextArea
app.TextArea = uitextarea(app.UIFigure);
app.TextArea.Position = [116 14 151 60];
app.TextArea.Value = {'This is some text.'};
% Create TabGroup
app.TabGroup = uitabgroup(app.UIFigure);
app.TabGroup.Position = [100 82 325 280]
% Create Tab
app.Tab = uitab(app.TabGroup);
app.Tab.Title = 'Tab';
% Create Tab2
app.Tab2 = uitab(app.TabGroup);
app.Tab2.Title = 'Tab2';
end
end
methods (Access = public)
% Construct app
function app = DOMdemo()
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
If you have to use mlapptools in startupFcn, you can do so using a timer (the timer runs on a different thread, which allows the App to properly finish initializing):
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
start(timer('TimerFcn', @(x,y)app.customizeElements(), 'StartDelay', 10));
end
function customizeElements(app)
[hWin, widgetID] = mlapptools.getWebElements(app.TabGroup);
[childIDs] = mlapptools.getChildNodeIDs(hWin, widgetID);
mlapptools.setStyle(hWin, 'background', 'transparent', childIDs(2));
[childIDs] = mlapptools.getChildNodeIDs(hWin, childIDs(2));
mlapptools.setStyle(hWin, 'background', 'black', childIDs(4));
end
end
Note that it will only crash if the timer delay is too short.